MCPcopy
hub / github.com/argoproj/argo-cd / TestUpdateHealthStatusProgression

Function TestUpdateHealthStatusProgression

controller/appcontroller_test.go:2307–2409  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2305}
2306
2307func 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": `
2324apps/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 },

Callers

nothing calls this directly

Calls 8

requestAppRefreshMethod · 0.80
ContextMethod · 0.65
RunMethod · 0.65
ListMethod · 0.65
SleepMethod · 0.45

Tested by

no test coverage detected