@@ -70,6 +70,50 @@ func TestGetKuberneterVersion(t *testing.T) {
70
70
}
71
71
}
72
72
73
+ func TestMirrorCountry (t * testing.T ) {
74
+ // Set default disk size value in lieu of flag init
75
+ viper .SetDefault (humanReadableDiskSize , defaultDiskSize )
76
+
77
+ k8sVersion := constants .DefaultKubernetesVersion
78
+ var tests = []struct {
79
+ description string
80
+ k8sVersion string
81
+ imageRepository string
82
+ mirrorCountry string
83
+ cfg * cfg.ClusterConfig
84
+ }{
85
+ {
86
+ description : "image-repository none, image-mirror-country none" ,
87
+ imageRepository : "" ,
88
+ mirrorCountry : "" ,
89
+ },
90
+ {
91
+ description : "image-repository auto, image-mirror-country none" ,
92
+ imageRepository : "auto" ,
93
+ mirrorCountry : "" ,
94
+ },
95
+ {
96
+ description : "image-repository auto, image-mirror-country china" ,
97
+ imageRepository : "auto" ,
98
+ mirrorCountry : "cn" ,
99
+ },
100
+ }
101
+
102
+ for _ , test := range tests {
103
+ t .Run (test .description , func (t * testing.T ) {
104
+ cmd := & cobra.Command {}
105
+ viper .SetDefault (imageRepository , test .imageRepository )
106
+ viper .SetDefault (imageMirrorCountry , test .mirrorCountry )
107
+ config , _ , err := generateCfgFromFlags (cmd , k8sVersion , "none" )
108
+ if err != nil {
109
+ t .Fatalf ("Got unexpected error %v during config generation" , err )
110
+ }
111
+ // the result can still be "", but anyway
112
+ _ = config .KubernetesConfig .ImageRepository
113
+ })
114
+ }
115
+ }
116
+
73
117
func TestGenerateCfgFromFlagsHTTPProxyHandling (t * testing.T ) {
74
118
// Set default disk size value in lieu of flag init
75
119
viper .SetDefault (humanReadableDiskSize , defaultDiskSize )
0 commit comments