-
-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathget_test.go
47 lines (39 loc) · 1.04 KB
/
get_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
package setting
import (
"context"
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/traggo/server/model"
"github.com/traggo/server/test"
"github.com/traggo/server/test/fake"
)
func TestGet_noUser(t *testing.T) {
db := test.InMemoryDB(t)
defer db.Close()
settings, err := Get(context.Background(), db.DB)
require.NoError(t, err)
require.Equal(t, model.ThemeGruvboxDark, settings.Theme)
}
func TestGet_user_noSettings(t *testing.T) {
db := test.InMemoryDB(t)
defer db.Close()
db.User(1)
settings, err := Get(fake.User(1), db.DB)
require.NoError(t, err)
require.Equal(t, model.ThemeGruvboxDark, settings.Theme)
}
func TestGet_user(t *testing.T) {
db := test.InMemoryDB(t)
defer db.Close()
db.User(1)
db.Save(&model.UserSetting{
UserID: 1,
Theme: model.ThemeGruvboxLight,
DateLocale: model.DateLocaleGerman,
FirstDayOfTheWeek: time.Sunday.String(),
})
settings, err := Get(fake.User(1), db.DB)
require.NoError(t, err)
require.Equal(t, model.ThemeGruvboxLight, settings.Theme)
}