-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresource_test.go
77 lines (55 loc) · 1.35 KB
/
resource_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
69
70
71
72
73
74
75
76
77
package viaduct
import (
"testing"
"github.com/stretchr/testify/assert"
)
type testResourceType struct {
Value string
WithLock bool
}
func (t *testResourceType) OperationName() string {
return "Test"
}
func (t *testResourceType) Params() *ResourceParams {
if t.WithLock {
return NewResourceParamsWithLock()
}
return NewResourceParams()
}
func (t *testResourceType) PreflightChecks(log *Logger) error {
return nil
}
func (t *testResourceType) Run(log *Logger) error {
return nil
}
func newTestResource(value string) *testResourceType {
return &testResourceType{Value: value}
}
func newTestResourceWithLock(value string) *testResourceType {
return &testResourceType{Value: value, WithLock: true}
}
var testResource = newTestResource("test")
func TestSetKind(t *testing.T) {
t.Parallel()
var r Resource
err := r.setKind(testResource)
assert.NoError(t, err)
assert.Equal(t, ResourceKind("testResourceType"), r.ResourceKind)
}
func TestSetID(t *testing.T) {
t.Parallel()
r := Resource{}
err := r.setKind(testResource)
assert.NoError(t, err)
err = r.setID()
assert.NoError(t, err)
assert.Contains(t, string(r.ResourceID), "testResourceType")
}
func TestNewResource(t *testing.T) {
t.Parallel()
t.Run("error if invalid dependency", func(t *testing.T) {
t.Parallel()
_, err := newResource([]*Resource{{}})
assert.Error(t, err)
})
}