(t *testing.T)
| 17 | ) |
| 18 | |
| 19 | func TestAppCreationInOtherNamespace(t *testing.T) { |
| 20 | ctx := Given(t) |
| 21 | ctx. |
| 22 | Path(guestbookPath). |
| 23 | SetAppNamespace(AppNamespace()). |
| 24 | When(). |
| 25 | CreateApp(). |
| 26 | Then(). |
| 27 | Expect(SyncStatusIs(SyncStatusCodeOutOfSync)). |
| 28 | And(func(app *Application) { |
| 29 | assert.Equal(t, ctx.AppName(), app.Name) |
| 30 | assert.Equal(t, AppNamespace(), app.Namespace) |
| 31 | assert.Equal(t, RepoURL(RepoURLTypeFile), app.Spec.GetSource().RepoURL) |
| 32 | assert.Equal(t, guestbookPath, app.Spec.GetSource().Path) |
| 33 | assert.Equal(t, ctx.DeploymentNamespace(), app.Spec.Destination.Namespace) |
| 34 | assert.Equal(t, KubernetesInternalAPIServerAddr, app.Spec.Destination.Server) |
| 35 | }). |
| 36 | Expect(NamespacedEvent(ctx.AppNamespace(), EventReasonResourceCreated, "create")). |
| 37 | And(func(_ *Application) { |
| 38 | // app should be listed |
| 39 | output, err := RunCli("app", "list") |
| 40 | require.NoError(t, err) |
| 41 | assert.Contains(t, output, ctx.AppName()) |
| 42 | }). |
| 43 | When(). |
| 44 | // ensure that create is idempotent |
| 45 | CreateApp(). |
| 46 | Then(). |
| 47 | Given(). |
| 48 | Revision("master"). |
| 49 | When(). |
| 50 | // ensure that update replaces spec and merge labels and annotations |
| 51 | And(func() { |
| 52 | errors.NewHandler(t).FailOnErr(AppClientset.ArgoprojV1alpha1().Applications(AppNamespace()).Patch(t.Context(), |
| 53 | ctx.AppName(), types.MergePatchType, []byte(`{"metadata": {"labels": { "test": "label" }, "annotations": { "test": "annotation" }}}`), metav1.PatchOptions{})) |
| 54 | }). |
| 55 | CreateApp("--upsert"). |
| 56 | Then(). |
| 57 | And(func(app *Application) { |
| 58 | assert.Equal(t, "label", app.Labels["test"]) |
| 59 | assert.Equal(t, "annotation", app.Annotations["test"]) |
| 60 | assert.Equal(t, "master", app.Spec.GetSource().TargetRevision) |
| 61 | }) |
| 62 | } |
| 63 | |
| 64 | func TestForbiddenNamespace(t *testing.T) { |
| 65 | ctx := Given(t) |
nothing calls this directly
no test coverage detected