mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-21 12:33:00 +02:00
add unit-test
This commit is contained in:
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user