Skip to content

Commit

Permalink
Building out tests for formats
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolmholmes committed Feb 1, 2024
1 parent b5d6f19 commit b90fa03
Show file tree
Hide file tree
Showing 21 changed files with 11,374 additions and 6 deletions.
2 changes: 1 addition & 1 deletion integration/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestContexts(t *testing.T) {
TestDir: "testdata/contexts",
Commands: []Command{
{
Command: "config get-contexts",
Arguments: "config get-contexts",
ExpectedCode: 0,
ExpectedError: nil,
ExpectedOutput: "get-contexts.txt",
Expand Down
4 changes: 2 additions & 2 deletions integration/dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestDashboard(t *testing.T) {
TestDir: "testdata/dashboards",
Commands: []Command{
{
Command: "get Dashboard.ReciqtgGk",
Arguments: "get Dashboard.ReciqtgGk",
ExpectedCode: 0,
ExpectedError: nil,
ExpectedOutput: "ReciqtgGk.json",
Expand All @@ -28,7 +28,7 @@ func TestDashboard(t *testing.T) {
TestDir: "testdata/dashboards",
Commands: []Command{
{
Command: "get missing-dashboard",
Arguments: "get missing-dashboard",
ExpectedCode: 1,
},
},
Expand Down
55 changes: 55 additions & 0 deletions integration/formats_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package integration_test

import (
"fmt"
"testing"

"github.com/grafana/grizzly/pkg/testutil"
)

func TestFormats(t *testing.T) {
ticker := testutil.PingService(testutil.GetUrl())
defer ticker.Stop()

tests := []struct {
Name string
PushCmd string
Expected string
}{
{
Name: "Read json/flat/onlyspec, write json/dirs/spec",
PushCmd: "push -s -k Dashboard -f general json/flat/onlyspec",
Expected: "json/dirs/spec",
},
}
grizzlyTests := []GrizzlyTest{}
for _, test := range tests {
grizzlyTest := GrizzlyTest{
Name: test.Name,
TestDir: "testdata/formats",
Commands: []Command{
{
Command: "./start-grafana.sh",
},
{
Arguments: test.PushCmd,
ExpectedCode: 0,
ExpectedError: nil,
},
{
Arguments: "pull temp",
ExpectedCode: 0,
ExpectedError: nil,
},
{
Command: "diff",
Arguments: fmt.Sprintf("-ur temp %s", test.Expected),
ExpectedCode: 0,
ExpectedError: nil,
},
},
}
grizzlyTests = append(grizzlyTests, grizzlyTest)
}
RunTests(t, grizzlyTests)
}
Loading

0 comments on commit b90fa03

Please sign in to comment.