Skip to content

Commit

Permalink
Test the case where a dashboard has no specified folder
Browse files Browse the repository at this point in the history
Closes #201
A bug that is already fixed but untested
  • Loading branch information
julienduchesne committed Feb 2, 2024
1 parent e4c06d7 commit 09e310e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
17 changes: 17 additions & 0 deletions integration/dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions integration/testdata/dashboards/no-folder.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 9 additions & 5 deletions integration/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 09e310e

Please sign in to comment.