diff --git a/integration/dashboard_test.go b/integration/dashboard_test.go index f894b8ed..a3a4c43b 100644 --- a/integration/dashboard_test.go +++ b/integration/dashboard_test.go @@ -36,6 +36,23 @@ func TestDashboard(t *testing.T) { }) }) + t.Run("Apply dashboard - no folder", func(t *testing.T) { + runTest(t, GrizzlyTest{ + TestDir: dir, + RunOnContexts: allContexts, + Commands: []Command{ + { + Command: "apply no-folder.yml", + ExpectedOutput: "Dashboard.no-folder added\n", + }, + { + Command: "get Dashboard.no-folder", + ExpectedOutputContains: "folder: general", + }, + }, + }) + }) + t.Run("Diff dashboard - invalid auth", func(t *testing.T) { runTest(t, GrizzlyTest{ TestDir: dir, diff --git a/integration/testdata/dashboards/no-folder.yml b/integration/testdata/dashboards/no-folder.yml new file mode 100644 index 00000000..5a14a377 --- /dev/null +++ b/integration/testdata/dashboards/no-folder.yml @@ -0,0 +1,11 @@ +apiVersion: grizzly.grafana.com/v1alpha1 +kind: Dashboard +metadata: + name: no-folder +spec: + schemaVersion: 17 + tags: + - templated + timezone: browser + title: No Folder + uid: no-folder diff --git a/integration/utils_test.go b/integration/utils_test.go index 68584df1..f7eac91f 100644 --- a/integration/utils_test.go +++ b/integration/utils_test.go @@ -14,11 +14,12 @@ import ( var allContexts = []string{"default", "subpath", "basic_auth"} type Command struct { - Command string - ExpectedCode int - ExpectedLogsContain string - ExpectedOutput string - ExpectedOutputFile string + Command string + ExpectedCode int + ExpectedLogsContain string + ExpectedOutputContains string + ExpectedOutput string + ExpectedOutputFile string } type GrizzlyTest struct { TestDir string @@ -62,6 +63,9 @@ func runTest(t *testing.T, test GrizzlyTest) { if command.ExpectedOutput != "" { require.Equal(t, command.ExpectedOutput, stdout) } + if command.ExpectedOutputContains != "" { + require.Contains(t, stdout, command.ExpectedOutputContains) + } } if test.Validate != nil { test.Validate(t)