mirror of
https://github.com/thegeeklab/wp-git-clone.git
synced 2024-11-14 19:30:40 +00:00
39 lines
652 B
Go
39 lines
652 B
Go
package plugin
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func Test_pluginOptions(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
envs map[string]string
|
|
want string
|
|
}{
|
|
{
|
|
name: "ensure default branch is set",
|
|
envs: map[string]string{
|
|
"CI_COMMIT_BRANCH": "",
|
|
},
|
|
want: "main",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
for key, value := range tt.envs {
|
|
t.Setenv(key, value)
|
|
}
|
|
|
|
got := New(func(_ context.Context) error { return nil })
|
|
|
|
_ = got.App.Run([]string{"wp-git-clone"})
|
|
_ = got.Validate()
|
|
_ = got.FlagsFromContext()
|
|
|
|
assert.EqualValues(t, tt.want, got.Settings.Repo.Branch)
|
|
}
|
|
}
|