@@ -22,42 +22,46 @@ import (
22
22
"github.com/GoogleContainerTools/skaffold/testutil"
23
23
)
24
24
25
- func TestIsUpdateCheckEnabledByEnvOrConfig (t * testing.T ) {
25
+ func TestIsUpdateCheckEnabled (t * testing.T ) {
26
26
tests := []struct {
27
27
description string
28
- envVariable string
28
+ enabled bool
29
29
configCheck bool
30
30
expected bool
31
31
}{
32
32
{
33
- description : "env variable is set to true" ,
34
- envVariable : "true" ,
35
- expected : true ,
36
- },
37
- {
38
- description : "env variable is set to false" ,
39
- envVariable : "false" ,
33
+ description : "globally disabled - disabled in config -> disabled" ,
34
+ enabled : false ,
35
+ configCheck : false ,
36
+ expected : false ,
40
37
},
41
38
{
42
- description : "env variable is set to random string" ,
43
- envVariable : "foo" ,
39
+ description : "globally enabled - disabled in config -> disabled" ,
40
+ enabled : true ,
41
+ configCheck : false ,
42
+ expected : false ,
44
43
},
45
44
{
46
- description : "env variable is empty and config is enabled" ,
45
+ description : "globally disabled - enabled in config -> disabled" ,
46
+ enabled : false ,
47
47
configCheck : true ,
48
- expected : true ,
48
+ expected : false ,
49
49
},
50
50
{
51
- description : "env variable is false but Global update-check config is true " ,
52
- envVariable : "false" ,
51
+ description : "globally enabled - enabled in config -> enabled " ,
52
+ enabled : true ,
53
53
configCheck : true ,
54
+ expected : true ,
54
55
},
55
56
}
56
57
for _ , test := range tests {
57
58
testutil .Run (t , test .description , func (t * testutil.T ) {
59
+ t .Override (& EnableCheck , test .enabled )
58
60
t .Override (& isConfigUpdateCheckEnabled , func (string ) bool { return test .configCheck })
59
- t .Override (& getEnv , func (string ) string { return test .envVariable })
60
- t .CheckDeepEqual (test .expected , isUpdateCheckEnabledByEnvOrConfig ("dummyconfig" ))
61
+
62
+ isEnabled := IsUpdateCheckEnabled ("dummyconfig" )
63
+
64
+ t .CheckDeepEqual (test .expected , isEnabled )
61
65
})
62
66
}
63
67
}
0 commit comments