mirror of
https://github.com/sot-tech/mochi.git
synced 2026-05-23 00:04:49 -07:00
bittorrent: pretty print nil for subtest naming
This commit is contained in:
@@ -23,10 +23,17 @@ func TestNew(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range table {
|
||||
t.Run(fmt.Sprintf("%#v expecting %s", tt.data, tt.expectedErr), func(t *testing.T) {
|
||||
t.Run(fmt.Sprintf("%#v expecting %s", tt.data, nilPrinter(tt.expectedErr)), func(t *testing.T) {
|
||||
got, err := NewEvent(tt.data)
|
||||
require.Equal(t, err, tt.expectedErr, "errors should equal the expected value")
|
||||
require.Equal(t, got, tt.expected, "events should equal the expected value")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func nilPrinter(err error) string {
|
||||
if err == nil {
|
||||
return "nil"
|
||||
}
|
||||
return err.Error()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user