package install import ( "net/http" "net/http/httptest" "testing" ) func TestLatestVersion(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte(`{"tag_name":"v0.71.0"}`)) })) defer ts.Close() old := latestAPI latestAPI = ts.URL defer func() { latestAPI = old }() v, err := latestVersion() if err != nil { t.Fatal(err) } if v != "v0.71.0" { t.Fatalf("version = %q", v) } } func TestPlatformName(t *testing.T) { p := platformName() if p == "" || len(p) < 5 { t.Fatalf("platform = %q", p) } }