-
Notifications
You must be signed in to change notification settings - Fork 0
/
dto_test.go
65 lines (61 loc) · 1.12 KB
/
dto_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
57
58
59
60
61
62
63
64
65
package cepgo_test
import (
"reflect"
"testing"
"github.com/victorfernandesraton/cepgo"
)
func TestValidCep(t *testing.T) {
tests := []struct {
cep string
expect string
wantErr error
}{
{
cep: "89010220",
expect: "89010220",
wantErr: nil,
},
{
cep: "890102-20",
expect: "89010220",
wantErr: nil,
},
{
cep: "89.010-220",
expect: "89010220",
wantErr: nil,
},
{
cep: "89.010.220",
expect: "89010220",
wantErr: nil,
},
{
cep: "89.010.22",
expect: "",
wantErr: cepgo.ErrorInvalidCepString,
},
{
cep: "89.010.229999",
expect: "",
wantErr: cepgo.ErrorInvalidCepString,
},
{
cep: "89.A10.220",
expect: "",
wantErr: cepgo.ErrorInvalidCepString,
},
}
for _, tt := range tests {
t.Run(tt.cep, func(t *testing.T) {
got, err := cepgo.ParseCEPString(tt.cep)
if err != tt.wantErr {
t.Errorf("CEPAPIViaCep.GetCEP() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.expect) {
t.Errorf("CEPAPIViaCep.GetCEP() = %v, want %v", got, tt.expect)
}
})
}
}