(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func 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 | } |
nothing calls this directly
no test coverage detected