-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_test.go
75 lines (63 loc) · 2.05 KB
/
user_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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package client_test
import (
"os"
"testing"
)
func TestNewUserNoPhoneNumber(test *testing.T) {
_, err := satisClient.CreateUser("", "")
if err == nil {
test.Fatalf("Expecting error not nil but instead is %v", err)
}
test.Logf("The beautifull error message is %v", err)
}
func TestNewUserInvalid(test *testing.T) {
_, err := validSatisClient.CreateUser("+393210987654", "")
if err == nil {
test.Fatalf("User creation has accomplished instead of expected failure")
}
test.Logf("The error is %v", err)
}
func TestNewUserValid(test *testing.T) {
user, err := validSatisClient.CreateUser(os.Getenv("PHONE_NUMBER"), "")
if err != nil {
test.Fatalf("User creation has failed %v", err)
}
test.Logf("User id is %s with phone number %s", user.ID, user.PhoneNumber)
}
func TestNewUserValidIdempotency(test *testing.T) {
user, err := validSatisClient.CreateUser(os.Getenv("PHONE_NUMBER"), "1")
if err != nil {
test.Fatalf("User creation has failed %v", err)
}
test.Logf("User id is %s with phone number %s", user.ID, user.PhoneNumber)
user2, err := validSatisClient.CreateUser(os.Getenv("PHONE_NUMBER"), "1")
if err != nil {
test.Fatalf("User2 creation has failed %v", err)
}
test.Logf("User id is %s with phone number %s", user2.ID, user2.PhoneNumber)
if user != user2 {
test.Fatal("User and User2 are not equals")
}
test.Logf("User and User2 are equal? %v", user == user2)
}
func TestGetUser(test *testing.T) {
_, err := satisClient.GetUser("fjoiafdaks")
if err == nil {
test.Fatalf("Expecting error not nil but instead is %v", err)
}
test.Logf("The beautifull error message is %v", err)
}
func TestGetUserList(test *testing.T) {
_, err := satisClient.UserList(40, "fdhuaihfaos", "fghufhifsdahiaf")
if err == nil {
test.Fatalf("Expecting error nil but instead is %v", err)
}
test.Logf("The beautifull error message is %v", err)
}
func TestGetUserListValid(test *testing.T) {
list, err := validSatisClient.UserList(40, "", "")
if err != nil {
test.Fatalf("Expecting error not nil but instead is %v", err)
}
test.Logf("The user list is %v", list)
}