pgraph: semaphore: Refactor semaphore size function and test

This commit is contained in:
James Shubin
2017-03-13 07:27:54 -04:00
parent e5dbb214a2
commit e4e39d820c
2 changed files with 28 additions and 10 deletions

View File

@@ -23,6 +23,19 @@ import (
"github.com/purpleidea/mgmt/resources"
)
func TestSemaSize(t *testing.T) {
pairs := map[string]int{
"id:42": 42,
":13": 13,
"some_id": 1,
}
for id, size := range pairs {
if i := SemaSize(id); i != size {
t.Errorf("sema id `%s`, expected: `%d`, got: `%d`", id, size, i)
}
}
}
func NewNoopResTestSema(name string, semas []string) *NoopResTest {
obj := &NoopResTest{
NoopRes: resources.NoopRes{