2015-05-14 21:56:15 +00:00
|
|
|
package libnetwork
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2021-04-06 00:24:47 +00:00
|
|
|
"github.com/docker/docker/libnetwork/types"
|
2015-05-14 21:56:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestErrorInterfaces(t *testing.T) {
|
2023-07-28 23:58:16 +00:00
|
|
|
badRequestErrorList := []error{ErrInvalidID(""), ErrInvalidName("")}
|
2015-05-14 21:56:15 +00:00
|
|
|
for _, err := range badRequestErrorList {
|
|
|
|
switch u := err.(type) {
|
2023-08-08 11:35:05 +00:00
|
|
|
case types.InvalidParameterError:
|
2015-05-14 21:56:15 +00:00
|
|
|
default:
|
2023-08-08 11:35:05 +00:00
|
|
|
t.Errorf("Failed to detect err %v is of type InvalidParameterError. Got type: %T", err, u)
|
2015-05-14 21:56:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-28 23:51:03 +00:00
|
|
|
maskableErrorList := []error{ManagerRedirectError("")}
|
2015-05-14 21:56:15 +00:00
|
|
|
for _, err := range maskableErrorList {
|
|
|
|
switch u := err.(type) {
|
|
|
|
case types.MaskableError:
|
|
|
|
default:
|
2023-07-21 18:52:48 +00:00
|
|
|
t.Errorf("Failed to detect err %v is of type MaskableError. Got type: %T", err, u)
|
2015-05-14 21:56:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-28 23:57:04 +00:00
|
|
|
notFoundErrorList := []error{&UnknownNetworkError{}, ErrNoSuchNetwork(""), ErrNoSuchEndpoint("")}
|
2015-05-14 21:56:15 +00:00
|
|
|
for _, err := range notFoundErrorList {
|
|
|
|
switch u := err.(type) {
|
|
|
|
case types.NotFoundError:
|
|
|
|
default:
|
2023-07-21 18:52:48 +00:00
|
|
|
t.Errorf("Failed to detect err %v is of type NotFoundError. Got type: %T", err, u)
|
2015-05-14 21:56:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-21 18:52:48 +00:00
|
|
|
forbiddenErrorList := []error{&ActiveContainerError{}}
|
2015-05-14 21:56:15 +00:00
|
|
|
for _, err := range forbiddenErrorList {
|
|
|
|
switch u := err.(type) {
|
|
|
|
case types.ForbiddenError:
|
|
|
|
default:
|
2023-07-21 18:52:48 +00:00
|
|
|
t.Errorf("Failed to detect err %v is of type ForbiddenError. Got type: %T", err, u)
|
2015-05-14 21:56:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|