forked from TrueCloudLab/distribution
registry/api/errorcode: TestErrorCodes: use sub-tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
57f9f31af9
commit
f884a079df
1 changed files with 41 additions and 37 deletions
|
@ -34,11 +34,14 @@ var ErrorCodeTest3 = Register("test.errors", ErrorDescriptor{
|
|||
// TestErrorCodes ensures that error code format, mappings and
|
||||
// marshaling/unmarshaling. round trips are stable.
|
||||
func TestErrorCodes(t *testing.T) {
|
||||
t.Parallel()
|
||||
if len(errorCodeToDescriptors) == 0 {
|
||||
t.Fatal("errors aren't loaded!")
|
||||
}
|
||||
|
||||
for ec, desc := range errorCodeToDescriptors {
|
||||
t.Run(ec.String(), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if ec != desc.Code {
|
||||
t.Fatalf("error code in descriptor isn't correct, %q != %q", ec, desc.Code)
|
||||
}
|
||||
|
@ -48,7 +51,7 @@ func TestErrorCodes(t *testing.T) {
|
|||
}
|
||||
|
||||
if ec.Message() != desc.Message {
|
||||
t.Fatalf("ec.Message doesn't mtach desc.Message: %q != %q", ec.Message(), desc.Message)
|
||||
t.Fatalf("ec.Message doesn't match desc.Message: %q != %q", ec.Message(), desc.Message)
|
||||
}
|
||||
|
||||
// Test (de)serializing the ErrorCode
|
||||
|
@ -85,6 +88,7 @@ func TestErrorCodes(t *testing.T) {
|
|||
if ec.Error() != expectedErrorString {
|
||||
t.Fatalf("unexpected return from %v.Error(): %q != %q", ec, ec.Error(), expectedErrorString)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue