@@ -83,50 +83,54 @@ func lcmd(format string, args ...interface{}) *Session {
83
83
return cmd ("" , format , args ... )
84
84
}
85
85
86
- // Run crictl and return the resulting session
87
- func (t * TestFramework ) Crictl (args string ) * Session {
88
- return lcmd ("crictl %s" , args ).Wait ()
89
- }
90
-
91
86
// Run crictl on the specified endpoint and return the resulting session
92
87
func (t * TestFramework ) CrictlWithEndpoint (endpoint , args string ) * Session {
93
88
return lcmd ("crictl --runtime-endpoint=%s %s" , endpoint , args ).Wait (time .Minute )
94
89
}
95
90
91
+ // Run crictl and expect exit, expectedOut, expectedErr
92
+ func (t * TestFramework ) CrictlExpect (
93
+ endpoint , args string , exit int , expectedOut , expectedErr string ,
94
+ ) {
95
+ // When
96
+ res := t .CrictlWithEndpoint (endpoint , args )
97
+
98
+ // Then
99
+ Expect (res ).To (Exit (exit ))
100
+ if expectedOut == "" {
101
+ Expect (string (res .Out .Contents ())).To (BeEmpty ())
102
+ } else {
103
+ Expect (res .Out ).To (Say (expectedOut ))
104
+ }
105
+ if expectedErr == "" {
106
+ Expect (string (res .Err .Contents ())).To (BeEmpty ())
107
+ } else {
108
+ Expect (res .Err ).To (Say (expectedErr ))
109
+ }
110
+ }
111
+
96
112
// Run crictl and expect success containing the specified output
97
113
func (t * TestFramework ) CrictlExpectSuccess (args , expectedOut string ) {
98
- t .CrictlExpectSuccessWithEndpoint ("" , args , expectedOut )
114
+ t .CrictlExpect ("" , args , 0 , expectedOut , "" )
99
115
}
100
116
101
117
// Run crictl and expect success containing the specified output
102
118
func (t * TestFramework ) CrictlExpectSuccessWithEndpoint (endpoint , args , expectedOut string ) {
103
- // When
104
- res := t .CrictlWithEndpoint (endpoint , args )
105
-
106
- // Then
107
- Expect (res ).To (Exit (0 ))
108
- Expect (res .Out ).To (Say (expectedOut ))
109
- Expect (string (res .Err .Contents ())).To (BeEmpty ())
119
+ t .CrictlExpect (endpoint , args , 0 , expectedOut , "" )
110
120
}
111
121
112
122
// Run crictl and expect error containing the specified outputs
113
123
func (t * TestFramework ) CrictlExpectFailure (
114
124
args string , expectedOut , expectedErr string ,
115
125
) {
116
- t .CrictlExpectFailureWithEndpoint ("" , args , expectedOut , expectedErr )
126
+ t .CrictlExpect ("" , args , 1 , expectedOut , expectedErr )
117
127
}
118
128
119
129
// Run crictl and expect failure containing the specified output
120
130
func (t * TestFramework ) CrictlExpectFailureWithEndpoint (
121
131
endpoint , args , expectedOut , expectedErr string ,
122
132
) {
123
- // When
124
- res := t .CrictlWithEndpoint (endpoint , args )
125
-
126
- // Then
127
- Expect (res ).To (Exit (1 ))
128
- Expect (res .Out ).To (Say (expectedOut ))
129
- Expect (res .Err ).To (Say (expectedErr ))
133
+ t .CrictlExpect (endpoint , args , 1 , expectedOut , expectedErr )
130
134
}
131
135
132
136
func SetupCrio () string {
0 commit comments