MCPcopy Create free account
hub / github.com/akash-network/provider / TestClusterErrorToHTTP

Function TestClusterErrorToHTTP

gateway/rest/cluster_errors_test.go:16–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestClusterErrorToHTTP(t *testing.T) {
17 tests := []struct {
18 name string
19 err error
20 expectedStatus int
21 }{
22 {"nil", nil, http.StatusOK},
23 {"apiserver_not_ready", stderrors.New("apiserver not ready"), http.StatusServiceUnavailable},
24 {"connection_refused", stderrors.New("connection refused"), http.StatusServiceUnavailable},
25 {"lease_not_found", kubeclienterrors.ErrLeaseNotFound, http.StatusNotFound},
26 {"no_deployment_for_lease", kubeclienterrors.ErrNoDeploymentForLease, http.StatusNotFound},
27 {"no_manifest_for_lease", kubeclienterrors.ErrNoManifestForLease, http.StatusNotFound},
28 {"no_service_for_lease", kubeclienterrors.ErrNoServiceForLease, http.StatusNotFound},
29 {"k8s_not_found", kubeErrors.NewNotFound(schema.GroupResource{}, "lease"), http.StatusNotFound},
30 {"unknown", stderrors.New("other"), http.StatusInternalServerError},
31 }
32 for _, tt := range tests {
33 t.Run(tt.name, func(t *testing.T) {
34 wrapped := clusterErrorToHTTP(tt.err)
35 require.Equal(t, tt.expectedStatus, httperror.StatusCodeFrom(wrapped))
36 })
37 }
38}

Callers

nothing calls this directly

Calls 3

StatusCodeFromFunction · 0.92
clusterErrorToHTTPFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected