File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -223,3 +223,54 @@ func TestArgsMatchKVList(t *testing.T) {
223223 }
224224 }
225225}
226+
227+ func TestArgsValidate (t * testing.T ) {
228+ tests := []struct {
229+ name string
230+ testArgs Args
231+ accepted map [string ]bool
232+ wantErr bool
233+ }{
234+ {
235+ "mapping keys are in the accepted set" ,
236+ Args {
237+ map [string ]map [string ]bool {
238+ "created" : {
239+ "today" : true ,
240+ },
241+ },
242+ },
243+
244+ map [string ]bool {
245+ "created" : true ,
246+ },
247+
248+ false ,
249+ },
250+ {
251+ "mapping keys are not in the accepted set" ,
252+ Args {
253+ map [string ]map [string ]bool {
254+ "created" : {
255+ "today" : true ,
256+ },
257+ },
258+ },
259+
260+ map [string ]bool {
261+ "created" : false ,
262+ },
263+
264+ true ,
265+ },
266+ }
267+ for _ , tt := range tests {
268+ t .Run (tt .name , func (t * testing.T ) {
269+ err := tt .testArgs .Validate (tt .accepted )
270+ if (err != nil ) != tt .wantErr {
271+ t .Errorf ("Validate() error = %v, wantErr %v" , err , tt .wantErr )
272+ return
273+ }
274+ })
275+ }
276+ }
You can’t perform that action at this time.
0 commit comments