(t *testing.T)
| 2305 | } |
| 2306 | |
| 2307 | func TestUpdateHealthStatusProgression(t *testing.T) { |
| 2308 | app := newFakeAppWithHealthAndTime(health.HealthStatusDegraded, testTimestamp) |
| 2309 | deployment := kube.MustToUnstructured(&appsv1.Deployment{ |
| 2310 | TypeMeta: metav1.TypeMeta{ |
| 2311 | APIVersion: "apps/v1", |
| 2312 | Kind: "Deployment", |
| 2313 | }, |
| 2314 | ObjectMeta: metav1.ObjectMeta{ |
| 2315 | Name: "demo", |
| 2316 | Namespace: "default", |
| 2317 | }, |
| 2318 | Status: appsv1.DeploymentStatus{ |
| 2319 | ObservedGeneration: 0, |
| 2320 | }, |
| 2321 | }) |
| 2322 | configMapData := map[string]string{ |
| 2323 | "resource.customizations": ` |
| 2324 | apps/Deployment: |
| 2325 | health.lua: | |
| 2326 | hs = {} |
| 2327 | hs.status = "" |
| 2328 | hs.message = "" |
| 2329 | |
| 2330 | if obj.metadata ~= nil then |
| 2331 | if obj.metadata.labels ~= nil then |
| 2332 | current_status = obj.metadata.labels["status"] |
| 2333 | if current_status == "Degraded" then |
| 2334 | hs.status = "Missing" |
| 2335 | elseif current_status == "Missing" then |
| 2336 | hs.status = "Progressing" |
| 2337 | elseif current_status == "Progressing" then |
| 2338 | hs.status = "Healthy" |
| 2339 | elseif current_status == "Healthy" then |
| 2340 | hs.status = "Degraded" |
| 2341 | end |
| 2342 | end |
| 2343 | end |
| 2344 | |
| 2345 | return hs`, |
| 2346 | } |
| 2347 | ctrl := newFakeControllerWithResync(t.Context(), &fakeData{ |
| 2348 | apps: []runtime.Object{app, &defaultProj}, |
| 2349 | manifestResponse: &apiclient.ManifestResponse{ |
| 2350 | Manifests: []string{}, |
| 2351 | Namespace: test.FakeDestNamespace, |
| 2352 | Server: test.FakeClusterURL, |
| 2353 | Revision: "abc123", |
| 2354 | }, |
| 2355 | managedLiveObjs: map[kube.ResourceKey]*unstructured.Unstructured{ |
| 2356 | kube.GetResourceKey(deployment): deployment, |
| 2357 | }, |
| 2358 | configMapData: configMapData, |
| 2359 | manifestResponses: []*apiclient.ManifestResponse{ |
| 2360 | {}, |
| 2361 | {}, |
| 2362 | {}, |
| 2363 | {}, |
| 2364 | }, |
nothing calls this directly
no test coverage detected