Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -812,27 +812,21 @@ func TestContainerInvalidLeave(t *testing.T) {
|
| 812 | 812 |
}() |
| 813 | 813 |
|
| 814 | 814 |
err = ep.Leave(context.Background(), cnt) |
| 815 |
- if err == nil {
|
|
| 816 |
- t.Fatal("Expected to fail leave from an endpoint which has no active join")
|
|
| 817 |
- } |
|
| 818 |
- if _, ok := err.(types.ForbiddenError); !ok {
|
|
| 819 |
- t.Fatalf("Failed with unexpected error type: %T. Desc: %s", err, err.Error())
|
|
| 820 |
- } |
|
| 815 |
+ assert.Assert(t, is.ErrorType(err, errdefs.IsForbidden), "Expected to fail leave from an endpoint which has no active join") |
|
| 816 |
+ assert.Check(t, is.Error(err, "cannot leave endpoint with no attached sandbox")) |
|
| 821 | 817 |
|
| 822 |
- if err = ep.Leave(context.Background(), nil); err == nil {
|
|
| 823 |
- t.Fatalf("Expected to fail leave nil Sandbox")
|
|
| 824 |
- } |
|
| 825 |
- if _, ok := err.(types.InvalidParameterError); !ok {
|
|
| 826 |
- t.Fatalf("Unexpected error type returned: %T. Desc: %s", err, err.Error())
|
|
| 827 |
- } |
|
| 818 |
+ err = ep.Leave(context.Background(), nil) |
|
| 819 |
+ assert.Assert(t, is.ErrorType(err, errdefs.IsInvalidParameter), "Expected to fail leave with a nil Sandbox") |
|
| 820 |
+ // FIXME(thaJeztah): this error includes the raw data of the sandbox (as `<nil>`), which is not very informative |
|
| 821 |
+ assert.Check(t, is.Error(err, "invalid Sandbox passed to endpoint leave: <nil>")) |
|
| 828 | 822 |
|
| 829 | 823 |
fsbx := &libnetwork.Sandbox{}
|
| 830 |
- if err = ep.Leave(context.Background(), fsbx); err == nil {
|
|
| 831 |
- t.Fatalf("Expected to fail leave with invalid Sandbox")
|
|
| 832 |
- } |
|
| 833 |
- if _, ok := err.(types.InvalidParameterError); !ok {
|
|
| 834 |
- t.Fatalf("Unexpected error type returned: %T. Desc: %s", err, err.Error())
|
|
| 835 |
- } |
|
| 824 |
+ err = ep.Leave(context.Background(), fsbx) |
|
| 825 |
+ assert.Assert(t, is.ErrorType(err, errdefs.IsInvalidParameter), "Expected to fail leave with invalid Sandbox") |
|
| 826 |
+ //nolint:dupword // Ignore "Duplicate words (map[]) found (dupword)" |
|
| 827 |
+ // FIXME(thaJeztah): this error includes the raw data of the sandbox, which is not very human-readable or informative; |
|
| 828 |
+ // invalid Sandbox passed to endpoint leave: &{ {{ []} { [] [] []} map[] false false []} [] <nil> <nil> <nil> {{{} 0} {0 0}} [] map[] map[] <nil> 0 false false false false false [] {0 0} {0 0}}
|
|
| 829 |
+ assert.Check(t, is.ErrorContains(err, "invalid Sandbox passed to endpoint leave")) |
|
| 836 | 830 |
} |
| 837 | 831 |
|
| 838 | 832 |
func TestEndpointUpdateParent(t *testing.T) {
|