fix: use panel Python common catalog and track install jobs
This commit is contained in:
1 parent
248badd33e
commit
d7c007adc4
12 files changed
+202
-22
No files matched your search
@@ -125,6 +125,38 @@ func TestRuntimeCatalogUsesAaPanelProjectRoutes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPythonAvailableVersionsUseCommonCatalogWithoutArchiveFallback(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
name, body string
|
||||
want []string
|
||||
}{
|
||||
{"common differs from archive", `{"status":true,"sdk":{"streamline":[{"version":"3.12.15"},{"version":"3.13.17"}],"all":[{"version":"3.12.16"},{"version":"3.16.1"}]}}`, []string{"3.13.17", "3.12.15"}},
|
||||
{"no common catalog", `{"status":true,"sdk":{"all":[{"version":"3.12.16"}]}}`, nil},
|
||||
{"empty common catalog", `{"status":true,"sdk":{"streamline":[],"all":[{"version":"3.12.16"}]}}`, nil},
|
||||
{"unsafe or prerelease entries", `{"status":true,"sdk":{"streamline":[{"version":"3.13.17"},{"version":"3.14.0rc1"},{"version":"../../../tmp"},{"version":"3.12.15;id"}]}}`, []string{"3.13.17"}},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/project/python/list_py_version/stype" || r.Method != http.MethodPost {
|
||||
t.Errorf("unexpected Python catalog request: %s %s", r.Method, r.URL.Path)
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, _ = w.Write([]byte(test.body))
|
||||
}))
|
||||
defer server.Close()
|
||||
client := NewClient(server.URL, "test-key", false, time.Second)
|
||||
got, err := client.pythonCommonAvailableVersions(context.Background())
|
||||
if test.want == nil {
|
||||
if err == nil || !strings.Contains(err.Error(), "常用版本") {
|
||||
t.Fatalf("missing common catalog was silently accepted: %v", err)
|
||||
}
|
||||
} else if err != nil || !reflect.DeepEqual(got, test.want) {
|
||||
t.Fatalf("got %v, %v; want %v", got, err, test.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRuntimeCapabilitiesDoNotFailAsAGroup(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
Reference in new issue
Block a user