From 0627e4440b70a1645f19cd9f611320f547068b45 Mon Sep 17 00:00:00 2001 From: Joe Tsai Date: Mon, 26 Mar 2018 15:09:07 -0700 Subject: Enforce tests to provide a reason (#83) To prevent future developers from getting lazy, check that a reason is given as part of each test case. Checks are only given for cmpopts. The cmp tests lack reasons, which is future work. --- cmp/cmpopts/util_test.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cmp/cmpopts/util_test.go') diff --git a/cmp/cmpopts/util_test.go b/cmp/cmpopts/util_test.go index f532789..02c447f 100644 --- a/cmp/cmpopts/util_test.go +++ b/cmp/cmpopts/util_test.go @@ -731,6 +731,8 @@ func TestOptions(t *testing.T) { gotEqual = cmp.Equal(tt.x, tt.y, tt.opts...) }() switch { + case tt.reason == "": + t.Errorf("reason must be provided") case gotPanic == "" && tt.wantPanic: t.Errorf("expected Equal panic\nreason: %s", tt.reason) case gotPanic != "" && !tt.wantPanic: @@ -972,6 +974,8 @@ func TestPanic(t *testing.T) { }() switch { + case tt.reason == "": + t.Errorf("reason must be provided") case tt.wantPanic == "" && gotPanic != "": t.Errorf("unexpected panic message: %s\nreason: %s", gotPanic, tt.reason) case tt.wantPanic != "" && !strings.Contains(gotPanic, tt.wantPanic): -- cgit v1.2.3