@@ -3,6 +3,8 @@ package types
3
3
import (
4
4
"testing"
5
5
6
+ "github.com/pkg/errors"
7
+
6
8
"github.com/stretchr/testify/assert"
7
9
)
8
10
@@ -18,7 +20,7 @@ func TestSetNodeOptions(t *testing.T) {
18
20
DeltaVolume : VolumeMap {"/data" : 1 , "/data2" : 2 },
19
21
DeltaStorage : - 10 ,
20
22
}
21
- assert .Equal (t , ErrEmptyNodeName , o .Validate ())
23
+ assert .Equal (t , ErrEmptyNodeName , errors . Unwrap ( o .Validate () ))
22
24
23
25
o .Nodename = "nodename"
24
26
assert .NoError (t , o .Validate ())
@@ -43,22 +45,22 @@ func TestDeployOptions(t *testing.T) {
43
45
assert := assert .New (t )
44
46
45
47
o := & DeployOptions {Entrypoint : & Entrypoint {}}
46
- assert .Equal (ErrEmptyAppName , o .Validate ())
48
+ assert .Equal (ErrEmptyAppName , errors . Unwrap ( o .Validate () ))
47
49
48
50
o .Name = "testname"
49
- assert .Equal (ErrEmptyPodName , o .Validate ())
51
+ assert .Equal (ErrEmptyPodName , errors . Unwrap ( o .Validate () ))
50
52
51
53
o .Podname = "podname"
52
- assert .Equal (ErrEmptyImage , o .Validate ())
54
+ assert .Equal (ErrEmptyImage , errors . Unwrap ( o .Validate () ))
53
55
54
56
o .Image = "image"
55
- assert .Equal (ErrEmptyCount , o .Validate ())
57
+ assert .Equal (ErrEmptyCount , errors . Unwrap ( o .Validate () ))
56
58
57
59
o .Count = 1
58
- assert .Equal (ErrEmptyEntrypointName , o .Validate ())
60
+ assert .Equal (ErrEmptyEntrypointName , errors . Unwrap ( o .Validate () ))
59
61
60
62
o .Entrypoint .Name = "bad_entry_point"
61
- assert .Equal (ErrUnderlineInEntrypointName , o .Validate ())
63
+ assert .Equal (ErrUnderlineInEntrypointName , errors . Unwrap ( o .Validate () ))
62
64
63
65
o .Entrypoint .Name = "good-entry-point"
64
66
assert .NoError (o .Validate ())
@@ -68,7 +70,7 @@ func TestCopyOptions(t *testing.T) {
68
70
assert := assert .New (t )
69
71
70
72
o := & CopyOptions {}
71
- assert .Equal (ErrNoFilesToCopy , o .Validate ())
73
+ assert .Equal (ErrNoFilesToCopy , errors . Unwrap ( o .Validate () ))
72
74
73
75
o .Targets = map [string ][]string {
74
76
"workload_id" : {
@@ -83,10 +85,10 @@ func TestSendOptions(t *testing.T) {
83
85
assert := assert .New (t )
84
86
85
87
o := & SendOptions {}
86
- assert .Equal (ErrNoWorkloadIDs , o .Validate ())
88
+ assert .Equal (ErrNoWorkloadIDs , errors . Unwrap ( o .Validate () ))
87
89
88
90
o .IDs = []string {"workload_id1" , "workload_id2" }
89
- assert .Equal (ErrNoFilesToSend , o .Validate ())
91
+ assert .Equal (ErrNoFilesToSend , errors . Unwrap ( o .Validate () ))
90
92
91
93
o .Data = map [string ][]byte {
92
94
"filepath1" : []byte ("filecontent1" ),
@@ -99,13 +101,13 @@ func TestReplaceOptions(t *testing.T) {
99
101
assert := assert .New (t )
100
102
101
103
o := & ReplaceOptions {DeployOptions : DeployOptions {Entrypoint : & Entrypoint {}}}
102
- assert .Equal (ErrEmptyAppName , o .Validate ())
104
+ assert .Equal (ErrEmptyAppName , errors . Unwrap ( o .Validate () ))
103
105
104
106
o .DeployOptions .Name = "testname"
105
- assert .Equal (ErrEmptyEntrypointName , o .Validate ())
107
+ assert .Equal (ErrEmptyEntrypointName , errors . Unwrap ( o .Validate () ))
106
108
107
109
o .DeployOptions .Entrypoint .Name = "bad_entry_point"
108
- assert .Equal (ErrUnderlineInEntrypointName , o .Validate ())
110
+ assert .Equal (ErrUnderlineInEntrypointName , errors . Unwrap ( o .Validate () ))
109
111
110
112
o .DeployOptions .Entrypoint .Name = "good-entry-point"
111
113
assert .NoError (o .Validate ())
@@ -122,13 +124,13 @@ func TestValidatingAddNodeOptions(t *testing.T) {
122
124
assert := assert .New (t )
123
125
124
126
o := & AddNodeOptions {}
125
- assert .Equal (ErrEmptyNodeName , o .Validate ())
127
+ assert .Equal (ErrEmptyNodeName , errors . Unwrap ( o .Validate () ))
126
128
127
129
o .Nodename = "nodename"
128
- assert .Equal (ErrEmptyPodName , o .Validate ())
130
+ assert .Equal (ErrEmptyPodName , errors . Unwrap ( o .Validate () ))
129
131
130
132
o .Podname = "podname"
131
- assert .Equal (ErrEmptyNodeEndpoint , o .Validate ())
133
+ assert .Equal (ErrEmptyNodeEndpoint , errors . Unwrap ( o .Validate () ))
132
134
133
135
o .Endpoint = "tcp://endpoint:2376"
134
136
assert .NoError (o .Validate ())
@@ -138,7 +140,7 @@ func TestImageOptions(t *testing.T) {
138
140
assert := assert .New (t )
139
141
140
142
o := & ImageOptions {Step : - 1 }
141
- assert .Equal (ErrEmptyPodName , o .Validate ())
143
+ assert .Equal (ErrEmptyPodName , errors . Unwrap ( o .Validate () ))
142
144
143
145
o .Podname = "podname"
144
146
assert .NoError (o .Validate ())
0 commit comments