-
Notifications
You must be signed in to change notification settings - Fork 17
/
update_test.go
57 lines (45 loc) · 1.26 KB
/
update_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
package crud_test
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestMustUpdate(t *testing.T) {
assert.Nil(t, CreateUserProfiles())
nova := UserProfile{}
err := DB.Read(&nova, "SELECT * FROM user_profiles WHERE name = 'Nova'")
assert.Nil(t, err)
nova.Bio = "Hola"
assert.Nil(t, DB.Update(nova))
novac := UserProfile{}
err = DB.Read(&novac, "SELECT * FROM user_profiles WHERE name = 'Nova'")
assert.Nil(t, err)
assert.Equal(t, novac.Bio, "Hola")
assert.Equal(t, novac.Email, nova.Email)
assert.Equal(t, novac.Id, nova.Id)
}
func TestMustUpdateNotMatching(t *testing.T) {
assert.NotNil(t, DB.Update(&UserProfile{
Id: 123,
Name: "Yolo",
}))
}
/*func TestUpdate(t *testing.T) {
assert.Nil(t, CreateUserProfiles())
nova := UserProfile{}
err := DB.Read(&nova, "SELECT * FROM user_profile WHERE name = 'Nova'")
assert.Nil(t, err)
nova.Bio = "Y O L O"
assert.Nil(t, DB.Update(nova))
novac := UserProfile{}
err = DB.Read(&novac, "SELECT * FROM user_profile WHERE name = 'Nova'")
assert.Nil(t, err)
assert.Equal(t, novac.Bio, "Y O L O")
assert.Equal(t, novac.Email, nova.Email)
assert.Equal(t, novac.Id, nova.Id)
}
func TestUpdateNotMatching(t *testing.T) {
assert.Nil(t, DB.Update(&UserProfile{
Id: 123,
Name: "Yolo",
}))
}*/