@@ -235,3 +235,33 @@ func TestMaybePrintUpdateText(t *testing.T) {
235235 })
236236 }
237237}
238+
239+ func TestDownloadURL (t * testing.T ) {
240+ const urlBase = "https://github.com/kubernetes/minikube/releases/download/"
241+ type args struct {
242+ ver string
243+ os string
244+ arch string
245+ }
246+ tests := []struct {
247+ name string
248+ args args
249+ want string
250+ }{
251+ {"linux-amd64" , args {"foo" , "linux" , "amd64" }, urlBase + "foo/minikube-linux-amd64" },
252+ {"linux-arm64" , args {"foo" , "linux" , "arm64" }, urlBase + "foo/minikube-linux-arm64" },
253+ {"darwin-amd64" , args {"foo" , "darwin" , "amd64" }, urlBase + "foo/minikube-darwin-amd64" },
254+ {"darwin-arm64" , args {"foo" , "darwin" , "arm64" }, urlBase + "foo/minikube-darwin-arm64" },
255+ {"windows" , args {"foo" , "windows" , "amd64" }, urlBase + "foo/minikube-windows-amd64.exe" },
256+ {"linux-unset" , args {"foo-unset" , "linux" , "amd64" }, "https://github.com/kubernetes/minikube/releases" },
257+ {"linux-unset" , args {"foo-unset" , "windows" , "arm64" }, "https://github.com/kubernetes/minikube/releases" },
258+ {"windows-zzz" , args {"bar" , "windows" , "zzz" }, urlBase + "bar/minikube-windows-zzz.exe" },
259+ }
260+ for _ , tt := range tests {
261+ t .Run (tt .name , func (t * testing.T ) {
262+ if got := DownloadURL (tt .args .ver , tt .args .os , tt .args .arch ); got != tt .want {
263+ t .Errorf ("DownloadURL() = %v, want %v" , got , tt .want )
264+ }
265+ })
266+ }
267+ }
0 commit comments