-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_user_request_test.go
48 lines (36 loc) · 1.36 KB
/
create_user_request_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package usecase_test
import (
"testing"
"user-api/usecase"
"github.com/stretchr/testify/assert"
)
const msgErrorUnexpeted string = "Error to the instantiate CreateUserRequest"
func TestNewCreateUserRequestValidations(t *testing.T) {
names, emails, ages :=
[]string{"", "name1", "name2"},
[]string{"[email protected]", "", "[email protected]"},
[]int{13, 16, 0}
for i := range names {
request, err := usecase.NewCreateUserRequest(names[i], emails[i], ages[i])
assert.Nil(t, request, "CreateUserRequest created without request params")
assert.EqualError(t, err, "NewCreateUserRequest called without requested parameter")
}
}
func TestName(t *testing.T) {
nameExpected := "Name"
request, err := usecase.NewCreateUserRequest(nameExpected, "email", 12)
assert.Nil(t, err, msgErrorUnexpeted)
assert.Equal(t, request.Name(), nameExpected, "Name different from expected")
}
func TestEmail(t *testing.T) {
emailExpected := "Name"
request, err := usecase.NewCreateUserRequest("name", emailExpected, 12)
assert.Nil(t, err, msgErrorUnexpeted)
assert.Equal(t, request.Email(), emailExpected, "Email different from expected")
}
func TestAge(t *testing.T) {
ageExpected := 14
request, err := usecase.NewCreateUserRequest("name", "email", ageExpected)
assert.Nil(t, err, msgErrorUnexpeted)
assert.Equal(t, request.Age(), ageExpected, "Age different from expected")
}