Skip to content

Commit

Permalink
[CR] improve and refine error reporting in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arielshaqed committed Oct 14, 2020
1 parent 0b076f5 commit d7eb030
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions parade/parade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func scanIDs(t *testing.T, prefix string) []parade.TaskID {
t.Helper()
rows, err := db.Query(`SELECT id FROM tasks WHERE id LIKE format('%s%%', $1::text)`, prefix)
if err != nil {
t.Errorf("[I] select remaining IDs for prefix %s: %s", prefix, err)
t.Fatalf("[I] select remaining IDs for prefix %s: %s", prefix, err)
}

defer func() {
Expand All @@ -153,6 +153,9 @@ func scanIDs(t *testing.T, prefix string) []parade.TaskID {
}
gotIDs = append(gotIDs, id)
}
if err = rows.Err(); err != nil {
t.Fatalf("[I] scan rows: %s", err)
}
return gotIDs
}

Expand Down Expand Up @@ -252,14 +255,12 @@ func TestTaskStatusCodeValueScan(t *testing.T) {
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
var dst parade.TaskStatusCodeValue
if err := dst.Scan(c.in); err != nil {
if !errors.Is(err, c.err) {
t.Errorf("got err %v, expected %v", err, c.err)
}
} else {
if dst != c.out {
t.Errorf("expected %s, got %s", c.out, dst)
}
err := dst.Scan(c.in)
if !errors.Is(err, c.err) {
t.Errorf("got err %v, expected %v", err, c.err)
}
if err == nil && dst != c.out {
t.Errorf("expected %s, got %s", c.out, dst)
}
})
}
Expand Down

0 comments on commit d7eb030

Please sign in to comment.