Skip to content

Commit 734a929

Browse files
committed
Change test to use NewValidator with opts
1 parent a5214ec commit 734a929

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

validator_test.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,20 @@ func Test_Validator_requireNotBefore(t *testing.T) {
308308
}
309309
for _, tt := range tests {
310310
t.Run(tt.name, func(t *testing.T) {
311-
v := &Validator{
312-
leeway: tt.fields.leeway,
313-
timeFunc: tt.fields.timeFunc,
314-
verifyIat: tt.fields.requireNbf,
311+
opts := []ParserOption{
312+
WithLeeway(tt.fields.leeway),
313+
}
314+
315+
if tt.fields.requireNbf {
316+
opts = append(opts, WithNotBeforeRequired())
315317
}
318+
319+
if tt.fields.timeFunc != nil {
320+
opts = append(opts, WithTimeFunc(tt.fields.timeFunc))
321+
}
322+
323+
v := NewValidator(opts...)
324+
316325
if err := v.verifyNotBefore(tt.args.claims, tt.args.cmp, tt.args.required); (err != nil) && !errors.Is(err, tt.wantErr) {
317326
t.Errorf("validator.requireNotBefore() error = %v, wantErr %v", err, tt.wantErr)
318327
}

0 commit comments

Comments
 (0)