-
Notifications
You must be signed in to change notification settings - Fork 7
/
data_test.go
54 lines (45 loc) · 1.53 KB
/
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
50
51
52
53
54
package main
import (
"io"
"os"
"path/filepath"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func loadAppListFromTestData() (io.ReadCloser, error) {
res, err := os.Open(filepath.Join("testdata", "list.json"))
if err != nil {
return nil, err
}
return res, nil
}
func TestParseAppList(t *testing.T) {
res, err := loadAppListFromTestData()
if err != nil {
t.Error("Error loading app list", err)
}
defer res.Close()
list, err := parseAppList(res)
if err != nil {
t.Error("Error parsing app list", err)
}
assert.Equal(t, 10, len(list))
app := list["xyz.andy.beebui"]
assert.Equal(t, "xyz.andy.beebui", app.ID)
assert.Equal(t, "BeebUI", app.Name)
assert.Equal(t, "https://github.com/andydotxyz/beebui/blob/master/icon.png?raw=true", app.Icon)
assert.Equal(t, time.Date(2019, 03, 17, 19, 32, 14, 0, time.Local), app.Date)
assert.Equal(t, "A BBC Micro Emulator based on Fyne and skx/gobasic", app.Summary)
assert.Equal(t, "https://apps.fyne.io/apps/beebui.html", app.URL)
assert.Equal(t, "https://github.com/andydotxyz/beebui", app.Website)
assert.NotNil(t, app.Screenshots)
assert.Equal(t, 1, len(app.Screenshots))
shot := app.Screenshots[0]
assert.Equal(t, "https://github.com/andydotxyz/beebui/blob/master/beebui.png?raw=true", shot.Image)
assert.Equal(t, "desktop", shot.Type)
assert.Equal(t, "https://github.com/andydotxyz/beebui.git", app.Source.Git)
assert.Equal(t, "github.com/andydotxyz/beebui/cmd/beebui", app.Source.Package)
assert.Equal(t, "", app.Version)
assert.Equal(t, "linux", app.Requires)
}