-
Notifications
You must be signed in to change notification settings - Fork 0
/
guard_minlength_test.go
56 lines (53 loc) · 974 Bytes
/
guard_minlength_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package guard
import (
"fmt"
"reflect"
"testing"
"github.com/bgsrb/guard/messages"
)
func Test_MinLength(t *testing.T) {
type fields struct {
name string
value interface{}
minlength int
}
tests := []struct {
name string
fields fields
want Argument
}{
{
name: "not_min_length",
fields: fields{
name: "",
value: "1",
minlength: 2,
},
want: Argument{
Error: fmt.Errorf(messages.MinLength, "", 2),
Name: "",
Value: "1",
},
}, {
name: "min_length",
fields: fields{
name: "",
value: "01",
minlength: 2,
},
want: Argument{
Error: nil,
Name: "",
Value: "01",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g := Guard(tt.fields.value, tt.fields.name)
if got := g.MinLength(tt.fields.minlength); !reflect.DeepEqual(got, tt.want) {
t.Errorf("guard.MinLength() = %+v, want %+v", got, tt.want)
}
})
}
}