/
status.go
52 lines (46 loc) · 1.33 KB
/
status.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
package storagetest
import (
"testing"
"time"
radio "github.com/R-a-dio/valkyrie"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func (suite *Suite) TestStatusStore(t *testing.T) {
ss := suite.Storage(t).Status(suite.ctx)
in := radio.Status{
User: radio.User{
DJ: radio.DJ{
ID: 500,
},
},
Song: radio.Song{
Metadata: "testing data",
DatabaseTrack: &radio.DatabaseTrack{
TrackID: 1500,
},
},
SongInfo: radio.SongInfo{
Start: time.Date(2000, time.April, 1, 5, 6, 7, 8, time.UTC),
End: time.Date(2010, time.February, 10, 15, 16, 17, 18, time.UTC),
},
Listeners: 900,
StreamerName: "test",
Thread: "a cool thread",
RequestsEnabled: true,
}
err := ss.Store(in)
require.NoError(t, err)
out, err := ss.Load()
require.NoError(t, err)
assert.Condition(t, func() (success bool) {
return assert.Equal(t, in.User, out.User) &&
assert.Equal(t, in.Song, out.Song) &&
assert.WithinDuration(t, in.SongInfo.Start, out.SongInfo.Start, time.Second) &&
assert.WithinDuration(t, in.SongInfo.End, out.SongInfo.End, time.Second) &&
assert.Equal(t, in.Listeners, out.Listeners) &&
assert.Equal(t, in.StreamerName, out.StreamerName) &&
assert.Equal(t, in.Thread, out.Thread) &&
assert.Equal(t, in.RequestsEnabled, out.RequestsEnabled)
})
}