-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistry_test.go
53 lines (45 loc) · 1.06 KB
/
registry_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
package workering_test
import (
"testing"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/bonsai-oss/workering/v2"
)
func TestRegister(t *testing.T) {
// empty Worker
assert.Panics(t, func() {
workerName := uuid.New().String()
workering.Register(workering.RegisterSet{
Name: workerName,
Worker: nil,
})
})
// empty name
assert.Panics(t, func() {
workering.Register(workering.RegisterSet{
Name: "",
Worker: testWorkerBuilder(nil, nil),
})
})
// normal register call
assert.NotPanics(t, func() {
workerName := uuid.New().String()
workering.Register(workering.RegisterSet{
Name: workerName,
Worker: testWorkerBuilder(nil, nil),
})
assert.NotNil(t, workering.Get(workerName))
})
// panic on duplicate register
assert.Panics(t, func() {
workerName := uuid.New().String()
workering.Register(workering.RegisterSet{
Name: workerName,
Worker: testWorkerBuilder(nil, nil),
})
workering.Register(workering.RegisterSet{
Name: workerName,
Worker: testWorkerBuilder(nil, nil),
})
})
}