Skip to content

Commit

Permalink
Changed gottenReports to gotReports and improved error mesages in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiasgrenfeldt committed Sep 1, 2020
1 parent 3e31a70 commit 94083a3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions safehttp/plugins/collector/collector_test.go
Expand Up @@ -154,13 +154,13 @@ func TestValidReport(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var gottenReports []collector.Report
var gotReports []collector.Report
h := collector.HandlerBuilder{
Handler: func(r collector.Report) {
gottenReports = append(gottenReports, r)
gotReports = append(gotReports, r)
},
CSPHandler: func(r collector.CSPReport) {
t.Fatalf("expected CSP reports handler to not be called")
t.Fatalf("expected CSP reports handler not to be called")
},
}.Build()

Expand All @@ -170,7 +170,7 @@ func TestValidReport(t *testing.T) {
rr := safehttptest.NewResponseRecorder()
h.ServeHTTP(rr.ResponseWriter, req)

if diff := cmp.Diff(tt.want, gottenReports); diff != "" {
if diff := cmp.Diff(tt.want, gotReports); diff != "" {
t.Errorf("reports gotten mismatch (-want +got):\n%s", diff)
}

Expand Down Expand Up @@ -437,10 +437,10 @@ func TestInvalidRequest(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
h := collector.HandlerBuilder{
Handler: func(r collector.Report) {
t.Errorf("expected collector to not be called")
t.Errorf("expected collector not to be called")
},
CSPHandler: func(r collector.CSPReport) {
t.Errorf("expected collector to not be called")
t.Errorf("expected collector not to be called")
},
}.Build()

Expand Down

0 comments on commit 94083a3

Please sign in to comment.