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

Function TestAppCreationInOtherNamespace

test/e2e/app_namespaces_test.go:19–62  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func 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
64func TestForbiddenNamespace(t *testing.T) {
65 ctx := Given(t)

Callers

nothing calls this directly

Calls 15

NewHandlerFunction · 0.92
AppNamespaceFunction · 0.85
SyncStatusIsFunction · 0.85
RepoURLFunction · 0.85
NamespacedEventFunction · 0.85
CreateAppMethod · 0.80
RevisionMethod · 0.80
SetAppNamespaceMethod · 0.80
AppNamespaceMethod · 0.80
FailOnErrMethod · 0.80
AppNameMethod · 0.65
DeploymentNamespaceMethod · 0.65

Tested by

no test coverage detected