forked from taskcluster/taskcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcapabilities_test.go
41 lines (34 loc) · 1.02 KB
/
capabilities_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
package workerproto
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestEmptyCapabilities(t *testing.T) {
assert.Equal(t, EmptyCapabilities().List(), []string{})
}
func TestFromCapabilitiesList(t *testing.T) {
caps := []string{"abc", "def"}
assert.Equal(t, FromCapabilitiesList(caps).List(), caps)
}
func TestAdd(t *testing.T) {
caps := EmptyCapabilities()
caps.Add("abc")
assert.Equal(t, caps.List(), []string{"abc"})
}
func TestRemove(t *testing.T) {
caps := EmptyCapabilities()
caps.Add("graceful-termination")
assert.True(t, caps.Has("graceful-termination"))
caps.Remove("graceful-termination")
assert.False(t, caps.Has("graceful-termination"))
caps.Remove("graceful-termination")
assert.False(t, caps.Has("graceful-termination"))
}
func TestLimitTo(t *testing.T) {
caps1 := FromCapabilitiesList([]string{"abc", "def"})
caps2 := FromCapabilitiesList([]string{"def", "ghi"})
caps1.LimitTo(caps2)
assert.False(t, caps1.Has("abc"))
assert.True(t, caps1.Has("def"))
assert.False(t, caps1.Has("ghi"))
}