File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -223,3 +223,50 @@ 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+ name : "mapping keys are in the accepted set" ,
236+ testArgs : Args {
237+ map [string ]map [string ]bool {
238+ "created" : {
239+ "today" : true ,
240+ },
241+ },
242+ },
243+ accepted : map [string ]bool {
244+ "created" : true ,
245+ },
246+ wantErr : false ,
247+ },
248+ {
249+ name : "mapping keys are not in the accepted set" ,
250+ testArgs : Args {
251+ map [string ]map [string ]bool {
252+ "created" : {
253+ "today" : true ,
254+ },
255+ },
256+ },
257+ accepted : map [string ]bool {
258+ "created" : false ,
259+ },
260+ wantErr : true ,
261+ },
262+ }
263+ for _ , tt := range tests {
264+ t .Run (tt .name , func (t * testing.T ) {
265+ err := tt .testArgs .Validate (tt .accepted )
266+ if (err != nil ) != tt .wantErr {
267+ t .Errorf ("Validate() error = %v, wantErr %v" , err , tt .wantErr )
268+ return
269+ }
270+ })
271+ }
272+ }
You can’t perform that action at this time.
0 commit comments