Advertisement
MrShtein

Untitled

Feb 26th, 2024 (edited)
917
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.65 KB | None | 0 0
  1. func TestRequestDto(t *testing.T) {
  2.     testCases := []struct {
  3.         desc   string
  4.         input  GetCategoryRequestDto
  5.         expect error
  6.     }{
  7.         {
  8.             desc: "is valid dto",
  9.             input: GetCategoryRequestDto{
  10.                 ID: "00000000-0000-0000-1000-000000000000",
  11.             },
  12.             expect: nil,
  13.         },
  14.         {
  15.             desc: "not valid dto: ID is not uuid",
  16.             input: GetCategoryRequestDto{
  17.                 ID: "00000000-0000-0000-1000",
  18.             },
  19.             expect: InvalidUUIDErr,
  20.         },
  21.     }
  22.     for _, tc := range testCases {
  23.         t.Run(tc.desc, func(t *testing.T) {
  24.             got := tc.input.Validate()
  25.             if !errors.Is(got, tc.expect) {
  26.                 t.Errorf("Incorrected result. Expect %s, got nil", tc.expect)
  27.             }
  28.         })
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement