-
Notifications
You must be signed in to change notification settings - Fork 2
/
data_test.go
49 lines (36 loc) · 910 Bytes
/
data_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
package main
import (
"testing"
"time"
"fyne.io/fyne/v2/test"
"github.com/stretchr/testify/assert"
)
func TestNewCityStore(t *testing.T) {
a := test.NewApp()
s := newCityStore(a.Preferences())
assert.Equal(t, 1, len(s.list))
}
func TestCityStore_Add(t *testing.T) {
a := test.NewApp()
s := newCityStore(a.Preferences())
s.add(newTestCity())
assert.Equal(t, 2, len(s.list))
s = newCityStore(a.Preferences())
assert.Equal(t, 2, len(s.list))
}
func TestCityStore_Remove(t *testing.T) {
a := test.NewApp()
s := newCityStore(a.Preferences())
s.remove(0)
assert.Equal(t, 0, len(s.list))
// reset to always have 1
s = newCityStore(a.Preferences())
assert.Equal(t, 1, len(s.list))
}
func TestNewCity(t *testing.T) {
c := newTestCity()
assert.Equal(t, time.Now().Location(), c.localTime.Location())
}
func newTestCity() *city {
return newCity("Local", "Here", photo{}, time.Local)
}