harness-drone/plugin/admission/open_test.go

37 lines
718 B
Go
Raw Normal View History

2019-02-19 23:56:41 +00:00
// Copyright 2019 Drone.IO Inc. All rights reserved.
// Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file.
// +build !oss
2019-02-19 23:56:41 +00:00
package admission
import (
"testing"
"github.com/drone/drone/core"
"github.com/golang/mock/gomock"
)
func TestOpen(t *testing.T) {
controller := gomock.NewController(t)
defer controller.Finish()
user := &core.User{Login: "octocat"}
err := Open(false).Admit(noContext, user)
if err != nil {
t.Error(err)
}
err = Open(true).Admit(noContext, user)
if err == nil {
t.Errorf("Expect error when open admission is closed")
}
2019-09-19 05:52:13 +00:00
user.ID = 1
err = Open(true).Admit(noContext, user)
if err != nil {
t.Error(err)
}
2019-02-19 23:56:41 +00:00
}