services_test.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package apiv1
  2. import (
  3. "testing"
  4. )
  5. func TestType_String(t *testing.T) {
  6. tests := []struct {
  7. name string
  8. t Type
  9. want string
  10. }{
  11. {"default", "", "softcas"},
  12. {"SoftCAS", SoftCAS, "softcas"},
  13. {"CloudCAS", CloudCAS, "cloudcas"},
  14. {"UnknownCAS", "UnknownCAS", "unknowncas"},
  15. }
  16. for _, tt := range tests {
  17. t.Run(tt.name, func(t *testing.T) {
  18. if got := tt.t.String(); got != tt.want {
  19. t.Errorf("Type.String() = %v, want %v", got, tt.want)
  20. }
  21. })
  22. }
  23. }
  24. func TestNotImplementedError_Error(t *testing.T) {
  25. type fields struct {
  26. Message string
  27. }
  28. tests := []struct {
  29. name string
  30. fields fields
  31. want string
  32. }{
  33. {"default", fields{""}, "not implemented"},
  34. {"with message", fields{"method not supported"}, "method not supported"},
  35. }
  36. for _, tt := range tests {
  37. t.Run(tt.name, func(t *testing.T) {
  38. e := NotImplementedError{
  39. Message: tt.fields.Message,
  40. }
  41. if got := e.Error(); got != tt.want {
  42. t.Errorf("NotImplementedError.Error() = %v, want %v", got, tt.want)
  43. }
  44. })
  45. }
  46. }
  47. func TestNotImplementedError_StatusCode(t *testing.T) {
  48. type fields struct {
  49. Message string
  50. }
  51. tests := []struct {
  52. name string
  53. fields fields
  54. want int
  55. }{
  56. {"default", fields{""}, 501},
  57. {"with message", fields{"method not supported"}, 501},
  58. }
  59. for _, tt := range tests {
  60. t.Run(tt.name, func(t *testing.T) {
  61. s := NotImplementedError{
  62. Message: tt.fields.Message,
  63. }
  64. if got := s.StatusCode(); got != tt.want {
  65. t.Errorf("NotImplementedError.StatusCode() = %v, want %v", got, tt.want)
  66. }
  67. })
  68. }
  69. }