From b81c82d1c8d8edfdd94d38143b1ca6bf2478d752 Mon Sep 17 00:00:00 2001 From: Rahul Date: Fri, 11 Aug 2023 21:44:16 +0530 Subject: [PATCH] refactor: add cp command in dashboard sort test (#2278) * refactor: add cp command in dashboard sort test --- cmd/tools/grafana/dashboard_test.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/tools/grafana/dashboard_test.go b/cmd/tools/grafana/dashboard_test.go index db7a51629..b1ede5cf6 100644 --- a/cmd/tools/grafana/dashboard_test.go +++ b/cmd/tools/grafana/dashboard_test.go @@ -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) }) @@ -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) } }) } @@ -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 }