add unit-test

This commit is contained in:
yw-liu 2020-04-16 22:21:09 +08:00 committed by GitHub
parent 34a6ec250f
commit 4f8d074e00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,42 @@
package buildcontext
import (
"github.com/GoogleContainerTools/kaniko/testutil"
"os"
"testing"
)
func TestGetGitPullMethod(t *testing.T) {
tests := []struct {
setEnv func()
expectedValue string
}{
{
setEnv: func() {},
expectedValue: "https",
},
{
setEnv: func() {
_ = os.Setenv(gitPullMethodEnvKey, "http")
},
expectedValue: "http",
},
{
setEnv: func() {
_ = os.Setenv(gitPullMethodEnvKey, "https")
},
expectedValue: "https",
},
{
setEnv: func() {
_ = os.Setenv(gitPullMethodEnvKey, "unknown")
},
expectedValue: "https",
},
}
for _, tt := range tests {
tt.setEnv()
testutil.CheckDeepEqual(t, getGitPullMethod(), tt.expectedValue)
}
}