fix(testing): compare expected error messages against actual (#1857)
* fix(testing): compare expected error messages against actual * remove nonsense * remove nonsense * add expected error message for bucket not found * oopspull/10616/head
parent
58ff2c4eec
commit
78d0fc2b17
|
@ -516,6 +516,7 @@ func (s *BucketService) FindBucket(ctx context.Context, filter platform.BucketFi
|
|||
return nil, &platform.Error{
|
||||
Code: platform.ENotFound,
|
||||
Op: s.OpPrefix + platform.OpFindBucket,
|
||||
Msg: "bucket not found",
|
||||
Err: ErrNotFound,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ func (s *Service) FindOrganizations(ctx context.Context, filter platform.Organiz
|
|||
return orgs, 0, &platform.Error{
|
||||
Code: platform.ENotFound,
|
||||
Op: op,
|
||||
Msg: OpPrefix + platform.OpFindOrganizations,
|
||||
Msg: errOrganizationNotFound,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -945,7 +945,7 @@ func FindBucket(
|
|||
err: &platform.Error{
|
||||
Code: platform.ENotFound,
|
||||
Op: platform.OpFindBucket,
|
||||
Msg: "no results found",
|
||||
Msg: "bucket not found",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -295,7 +295,7 @@ func FindOrganizationByID(
|
|||
err: &platform.Error{
|
||||
Code: platform.ENotFound,
|
||||
Op: platform.OpFindOrganizationByID,
|
||||
Msg: "",
|
||||
Msg: "organization not found",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -21,6 +21,10 @@ func diffErrors(actual, expected error, t *testing.T) {
|
|||
}
|
||||
|
||||
func diffPlatformErrors(name string, actual, expected error, opPrefix string, t *testing.T) {
|
||||
if expected == nil && actual == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if expected == nil && actual != nil {
|
||||
t.Fatalf("%s failed, unexpected error %s", name, actual.Error())
|
||||
}
|
||||
|
@ -29,13 +33,17 @@ func diffPlatformErrors(name string, actual, expected error, opPrefix string, t
|
|||
t.Fatalf("%s failed, expected error %s but received nil", name, expected.Error())
|
||||
}
|
||||
|
||||
if expected != nil && actual != nil && platform.ErrorCode(expected) != platform.ErrorCode(actual) {
|
||||
if platform.ErrorCode(expected) != platform.ErrorCode(actual) {
|
||||
t.Fatalf("%s failed, expected error %q but received error code %q", name, platform.ErrorCode(expected), platform.ErrorCode(actual))
|
||||
}
|
||||
|
||||
if expected != nil && actual != nil && opPrefix+platform.ErrorOp(expected) != platform.ErrorOp(actual) {
|
||||
if opPrefix+platform.ErrorOp(expected) != platform.ErrorOp(actual) {
|
||||
t.Fatalf("%s failed, expected error %q but received error op %q", name, opPrefix+platform.ErrorOp(expected), platform.ErrorOp(actual))
|
||||
}
|
||||
|
||||
if platform.ErrorMessage(expected) != platform.ErrorMessage(actual) {
|
||||
t.Fatalf("%s failed, expected error %q but received error message %q", name, platform.ErrorMessage(expected), platform.ErrorMessage(actual))
|
||||
}
|
||||
}
|
||||
|
||||
// MustIDBase16 is an helper to ensure a correct ID is built during testing.
|
||||
|
|
Loading…
Reference in New Issue