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

Function TestPersistRevisionHistory

controller/sync_test.go:27–63  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func 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
65func TestPersistManagedNamespaceMetadataState(t *testing.T) {
66 app := newFakeApp()

Callers

nothing calls this directly

Calls 9

newFakeControllerFunction · 0.85
newFakeAppFunction · 0.70
ContextMethod · 0.65
SyncAppStateMethod · 0.65
GetMethod · 0.65
ApplicationsMethod · 0.65
ArgoprojV1alpha1Method · 0.65
GetSourceMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected