Skip to content

Commit

Permalink
refactor: add cp command in dashboard sort test (#2278)
Browse files Browse the repository at this point in the history
* refactor: add cp command in dashboard sort test
  • Loading branch information
rahulguptajss authored Aug 11, 2023
1 parent 4e6ac58 commit b81c82d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cmd/tools/grafana/dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ func checkConnectNullValues(t *testing.T, path string, data []byte) {

func TestPanelChildPanels(t *testing.T) {
visitDashboards(
[]string{"../../../grafana/dashboards/cmode", "../../../grafana/dashboards/storagegrid"},
dashboards,
func(path string, data []byte) {
checkPanelChildPanels(t, shortPath(path), data)
})
Expand Down Expand Up @@ -1182,8 +1182,9 @@ func TestDashboardKeysAreSorted(t *testing.T) {
})
if string(sorted) != string(data) {
sortedPath := writeSorted(t, path, sorted)
t.Errorf("dashboard=%s should have sorted keys but does not. Sorted version created at path=%s",
path, sortedPath)
path = "grafana/dashboards/" + path
t.Errorf("dashboard=%s should have sorted keys but does not. Sorted version created at path=%s. Run cp %s %s",
path, sortedPath, sortedPath, path)
}
})
}
Expand All @@ -1209,7 +1210,11 @@ func writeSorted(t *testing.T, path string, sorted []byte) string {
t.Errorf("failed to write sorted json to file=%s err=%v", dest, err)
return ""
}
create.Close()
err = create.Close()
if err != nil {
t.Errorf("failed to close file=%s err=%v", dest, err)
return ""
}
return dest
}

Expand Down

0 comments on commit b81c82d

Please sign in to comment.