MCPcopy Index your code
hub / github.com/argoproj/argo-cd / TestProjectErrorToCondition

Function TestProjectErrorToCondition

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

Source from the content-addressed store, hash-verified

2409}
2410
2411func TestProjectErrorToCondition(t *testing.T) {
2412 app := newFakeApp()
2413 app.Spec.Project = "wrong project"
2414 ctrl := newFakeController(t.Context(), &fakeData{
2415 apps: []runtime.Object{app, &defaultProj},
2416 manifestResponse: &apiclient.ManifestResponse{
2417 Manifests: []string{},
2418 Namespace: test.FakeDestNamespace,
2419 Server: test.FakeClusterURL,
2420 Revision: "abc123",
2421 },
2422 managedLiveObjs: make(map[kube.ResourceKey]*unstructured.Unstructured),
2423 }, nil)
2424 key, _ := cache.MetaNamespaceKeyFunc(app)
2425 ctrl.appRefreshQueue.AddRateLimited(key)
2426 ctrl.requestAppRefresh(app.Name, CompareWithRecent.Pointer(), nil)
2427
2428 ctrl.processAppRefreshQueueItem()
2429
2430 obj, ok, err := ctrl.appInformer.GetIndexer().GetByKey(key)
2431 assert.True(t, ok)
2432 require.NoError(t, err)
2433 updatedApp := obj.(*v1alpha1.Application)
2434 assert.Equal(t, v1alpha1.ApplicationConditionInvalidSpecError, updatedApp.Status.Conditions[0].Type)
2435 assert.Equal(t, "Application referencing project wrong project which does not exist", updatedApp.Status.Conditions[0].Message)
2436 assert.Equal(t, v1alpha1.ApplicationConditionInvalidSpecError, updatedApp.Status.Conditions[0].Type)
2437}
2438
2439// Regression test: the NamespaceIndex indexer must not call setAppCondition
2440// when the project informer has not synced yet. Before the fix, both

Callers

nothing calls this directly

Calls 6

newFakeControllerFunction · 0.85
requestAppRefreshMethod · 0.80
PointerMethod · 0.80
newFakeAppFunction · 0.70
ContextMethod · 0.65

Tested by

no test coverage detected