(t *testing.T)
| 191 | } |
| 192 | |
| 193 | func TestAppStateManager_SyncAppState(t *testing.T) { |
| 194 | t.Parallel() |
| 195 | |
| 196 | type fixture struct { |
| 197 | application *v1alpha1.Application |
| 198 | project *v1alpha1.AppProject |
| 199 | controller *ApplicationController |
| 200 | } |
| 201 | |
| 202 | setup := func(liveObjects map[kube.ResourceKey]*unstructured.Unstructured) *fixture { |
| 203 | app := newFakeApp() |
| 204 | app.Status.OperationState = nil |
| 205 | app.Status.History = nil |
| 206 | |
| 207 | if liveObjects == nil { |
| 208 | liveObjects = make(map[kube.ResourceKey]*unstructured.Unstructured) |
| 209 | } |
| 210 | |
| 211 | project := &v1alpha1.AppProject{ |
| 212 | ObjectMeta: metav1.ObjectMeta{ |
| 213 | Namespace: test.FakeArgoCDNamespace, |
| 214 | Name: "default", |
| 215 | }, |
| 216 | Spec: v1alpha1.AppProjectSpec{ |
| 217 | SignatureKeys: []v1alpha1.SignatureKey{{KeyID: "test"}}, |
| 218 | Destinations: []v1alpha1.ApplicationDestination{ |
| 219 | { |
| 220 | Namespace: "*", |
| 221 | Server: "*", |
| 222 | }, |
| 223 | }, |
| 224 | }, |
| 225 | } |
| 226 | data := fakeData{ |
| 227 | apps: []runtime.Object{app, project}, |
| 228 | manifestResponse: &apiclient.ManifestResponse{ |
| 229 | Manifests: []string{}, |
| 230 | Namespace: test.FakeDestNamespace, |
| 231 | Server: test.FakeClusterURL, |
| 232 | Revision: "abc123", |
| 233 | }, |
| 234 | managedLiveObjs: liveObjects, |
| 235 | } |
| 236 | ctrl := newFakeController(t.Context(), &data, nil) |
| 237 | |
| 238 | return &fixture{ |
| 239 | application: app, |
| 240 | project: project, |
| 241 | controller: ctrl, |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | t.Run("will fail the sync if finds shared resources", func(t *testing.T) { |
| 246 | // given |
| 247 | t.Parallel() |
| 248 | |
| 249 | sharedObject := kube.MustToUnstructured(&corev1.ConfigMap{ |
| 250 | TypeMeta: metav1.TypeMeta{ |
nothing calls this directly
no test coverage detected