harness-drone/plugin/admission/open_test.go

31 lines
628 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")
}
}