-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain_test.go
59 lines (46 loc) · 1.38 KB
/
main_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
58
59
package main
import (
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
)
func TestParsePlatforms(t *testing.T) {
fields := []string{"+windows", "+plan9", "-windows/386"}
plb, _ := NewPlatformBuilder()
plb = parsePlatforms(plb, fields)
pl := plb.Build()
expected := []Platform{
{OS("windows"), Arch("amd64")},
{OS("plan9"), Arch("386")},
{OS("plan9"), Arch("amd64")},
}
if diff := cmp.Diff(expected, pl, cmpopts.SortSlices(lessPlatforms)); diff != "" {
t.Errorf("manifest differs. (-got +want):\n%s", diff)
}
}
func TestParsePlatformsRemoveOS(t *testing.T) {
fields := []string{"+windows", "+plan9", "-windows"}
plb, _ := NewPlatformBuilder()
plb = parsePlatforms(plb, fields)
pl := plb.Build()
expected := []Platform{
{OS("plan9"), Arch("386")},
{OS("plan9"), Arch("amd64")},
}
if diff := cmp.Diff(expected, pl, cmpopts.SortSlices(lessPlatforms)); diff != "" {
t.Errorf("manifest differs. (-got +want):\n%s", diff)
}
}
func TestParsePlatformRemoveNothing(t *testing.T) {
fields := []string{"+windows", "-"}
plb, _ := NewPlatformBuilder()
plb = parsePlatforms(plb, fields)
pl := plb.Build()
expected := []Platform{
{OS("windows"), Arch("amd64")},
{OS("windows"), Arch("386")},
}
if diff := cmp.Diff(expected, pl, cmpopts.SortSlices(lessPlatforms)); diff != "" {
t.Errorf("manifest differs. (-got +want):\n%s", diff)
}
}