Skip to content

Commit

Permalink
refactor: make toJSON a test helper (kopia#4184)
Browse files Browse the repository at this point in the history
  • Loading branch information
julio-lopez authored Oct 18, 2024
1 parent d7a26b3 commit 98290b9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions repo/maintenance/maintenance_schedule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (s *formatSpecificTestSuite) TestMaintenanceSchedule(t *testing.T) {
s2, err := maintenance.GetSchedule(ctx, env.RepositoryWriter)
require.NoError(t, err, "unable to get schedule")

got, want := toJSON(s2), toJSON(sch)
got, want := toJSON(t, s2), toJSON(t, sch)
require.Equal(t, want, got, "unexpected schedule")
}

Expand Down Expand Up @@ -116,7 +116,12 @@ func TestTimeToAttemptNextMaintenance(t *testing.T) {
}
}

func toJSON(v interface{}) string {
b, _ := json.MarshalIndent(v, "", " ")
func toJSON(t *testing.T, v interface{}) string {
t.Helper()

b, err := json.MarshalIndent(v, "", " ")

require.NoError(t, err, "json marshal")

return string(b)
}

0 comments on commit 98290b9

Please sign in to comment.