harness-drone/plugin/admission/open_test.go
2019-02-19 15:56:41 -08:00

28 lines
612 B
Go

// 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.
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")
}
}