-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
55 lines (38 loc) · 998 Bytes
/
main_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
package main
import "testing"
func TestPerson(t *testing.T) {
id := createPerson(Person{Name: "mando", Age: 34})
p, ok := datalayer[1]
if id == 1 && ok && p.Name == "mando" && p.Age == 34 {
t.Log("person created successfully")
return
}
t.Error("create person failed", id, p, ok, datalayer)
}
func TestReadPerson(t *testing.T) {
p, err := readPerson(1)
if err != nil {
t.Error("read person error", err)
}
if p.Name != "mando" || p.Age != 34 {
t.Error("invalid name or age")
}
t.Log("read person successful", p)
}
// func TestUpdatePerson(t *testing.T) {
// p, err := updatePerson(1, Person{Name: "kp", Age: 20})
// if err != nil {
// t.Error("update person err", err)
// }
// if p.Name != "kp" && p.Age != 20 {
// t.Error("Name or age mismatch")
// }
// t.Log("update person successfull", p)
// }
func TestDeletePerson(t *testing.T){
err := deletePerson(1)
if err != nil {
t.Error("delete person error", err)
}
t.Log("delete person successful")
}