errors_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package libnetwork
  2. import (
  3. "testing"
  4. "github.com/docker/docker/libnetwork/types"
  5. )
  6. func TestErrorInterfaces(t *testing.T) {
  7. badRequestErrorList := []error{ErrInvalidID(""), ErrInvalidName("")}
  8. for _, err := range badRequestErrorList {
  9. switch u := err.(type) {
  10. case types.InvalidParameterError:
  11. default:
  12. t.Errorf("Failed to detect err %v is of type InvalidParameterError. Got type: %T", err, u)
  13. }
  14. }
  15. maskableErrorList := []error{ManagerRedirectError("")}
  16. for _, err := range maskableErrorList {
  17. switch u := err.(type) {
  18. case types.MaskableError:
  19. default:
  20. t.Errorf("Failed to detect err %v is of type MaskableError. Got type: %T", err, u)
  21. }
  22. }
  23. notFoundErrorList := []error{&UnknownNetworkError{}, ErrNoSuchNetwork(""), ErrNoSuchEndpoint("")}
  24. for _, err := range notFoundErrorList {
  25. switch u := err.(type) {
  26. case types.NotFoundError:
  27. default:
  28. t.Errorf("Failed to detect err %v is of type NotFoundError. Got type: %T", err, u)
  29. }
  30. }
  31. forbiddenErrorList := []error{&ActiveContainerError{}}
  32. for _, err := range forbiddenErrorList {
  33. switch u := err.(type) {
  34. case types.ForbiddenError:
  35. default:
  36. t.Errorf("Failed to detect err %v is of type ForbiddenError. Got type: %T", err, u)
  37. }
  38. }
  39. }