-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheapi_test.go
68 lines (57 loc) · 1.74 KB
/
eapi_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
60
61
62
63
64
65
66
67
68
package pkgcraft_test
import (
"testing"
"github.com/stretchr/testify/assert"
"golang.org/x/exp/slices"
. "github.com/pkgcraft/pkgcraft-go"
)
func TestEapiGlobals(t *testing.T) {
assert.True(t, len(EAPIS) > len(EAPIS_OFFICIAL))
for id, eapi := range EAPIS_OFFICIAL {
assert.True(t, EAPIS[id] == eapi)
}
assert.True(t, EAPIS[EAPI_LATEST_OFFICIAL.String()] == EAPI_LATEST_OFFICIAL)
}
func TestEapiRange(t *testing.T) {
// valid
eapis, err := EapiRange("..")
assert.Equal(t, len(eapis), len(EAPIS))
assert.Nil(t, err)
eapis, err = EapiRange("7..8")
assert.Equal(t, eapis, []*Eapi{EAPIS["7"]})
assert.Nil(t, err)
eapis, err = EapiRange("7..")
assert.Nil(t, err)
assert.Equal(t, eapis[0], EAPIS["7"])
eapis, err = EapiRange("8..8")
assert.Nil(t, err)
assert.Equal(t, len(eapis), 0)
// invalid
for _, s := range []string{"", "1", "..9999"} {
_, err = EapiRange(s)
assert.NotNil(t, err)
}
}
func TestEapiHas(t *testing.T) {
assert.True(t, EAPI_LATEST_OFFICIAL.Has("UsevTwoArgs"))
assert.False(t, EAPI_LATEST_OFFICIAL.Has("RepoIds"))
assert.False(t, EAPI_LATEST_OFFICIAL.Has("nonexistent"))
}
func TestEapiDepKeys(t *testing.T) {
assert.True(t, slices.Contains(EAPI_LATEST.DepKeys(), "BDEPEND"))
assert.False(t, slices.Contains(EAPI_LATEST.DepKeys(), "NONEXISTENT"))
}
func TestEapiMetadataKeys(t *testing.T) {
assert.True(t, slices.Contains(EAPI_LATEST.MetadataKeys(), "SLOT"))
assert.False(t, slices.Contains(EAPI_LATEST.MetadataKeys(), "NONEXISTENT"))
}
func TestEapiString(t *testing.T) {
for id, eapi := range EAPIS {
assert.Equal(t, eapi.String(), id)
}
}
func TestEapiCmp(t *testing.T) {
assert.Equal(t, EAPIS["7"].Cmp(EAPIS["8"]), -1)
assert.Equal(t, EAPIS["8"].Cmp(EAPIS["8"]), 0)
assert.Equal(t, EAPIS["8"].Cmp(EAPIS["7"]), 1)
}