(t *testing.T)
| 25 | ) |
| 26 | |
| 27 | func TestPersistRevisionHistory(t *testing.T) { |
| 28 | app := newFakeApp() |
| 29 | app.Status.OperationState = nil |
| 30 | app.Status.History = nil |
| 31 | |
| 32 | defaultProject := &v1alpha1.AppProject{ |
| 33 | ObjectMeta: metav1.ObjectMeta{ |
| 34 | Namespace: test.FakeArgoCDNamespace, |
| 35 | Name: "default", |
| 36 | }, |
| 37 | } |
| 38 | data := fakeData{ |
| 39 | apps: []runtime.Object{app, defaultProject}, |
| 40 | manifestResponse: &apiclient.ManifestResponse{ |
| 41 | Manifests: []string{}, |
| 42 | Namespace: test.FakeDestNamespace, |
| 43 | Server: test.FakeClusterURL, |
| 44 | Revision: "abc123", |
| 45 | }, |
| 46 | managedLiveObjs: make(map[kube.ResourceKey]*unstructured.Unstructured), |
| 47 | } |
| 48 | ctrl := newFakeController(t.Context(), &data, nil) |
| 49 | |
| 50 | // Sync with source unspecified |
| 51 | opState := &v1alpha1.OperationState{Operation: v1alpha1.Operation{ |
| 52 | Sync: &v1alpha1.SyncOperation{}, |
| 53 | }} |
| 54 | ctrl.appStateManager.SyncAppState(app, defaultProject, opState) |
| 55 | // Ensure we record spec.source into sync result |
| 56 | assert.Equal(t, app.Spec.GetSource(), opState.SyncResult.Source) |
| 57 | |
| 58 | updatedApp, err := ctrl.applicationClientset.ArgoprojV1alpha1().Applications(app.Namespace).Get(t.Context(), app.Name, metav1.GetOptions{}) |
| 59 | require.NoError(t, err) |
| 60 | require.Len(t, updatedApp.Status.History, 1) |
| 61 | assert.Equal(t, app.Spec.GetSource(), updatedApp.Status.History[0].Source) |
| 62 | assert.Equal(t, "abc123", updatedApp.Status.History[0].Revision) |
| 63 | } |
| 64 | |
| 65 | func TestPersistManagedNamespaceMetadataState(t *testing.T) { |
| 66 | app := newFakeApp() |
nothing calls this directly
no test coverage detected