Browse Source

Add ToURLE tests

pull/83/head
andrewheberle GitHub 4 years ago
parent
commit
2dd4a14d2f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 0 deletions
  1. +28
    -0
      cast_test.go

+ 28
- 0
cast_test.go View File

@@ -1285,3 +1285,31 @@ func TestToDurationE(t *testing.T) {
assert.Equal(t, test.expect, v, errmsg)
}
}

func TestToURLE(t *testing.T) {
type args struct {
i interface{}
}
tests := []struct {
name string
args args
wantU *url.URL
wantErr bool
}{
{"url", args{&url.URL{Scheme: "https", Host: "example.net", Path: "/"}}, &url.URL{Scheme: "https", Host: "example.net", Path: "/"}, false},
{"string", args{string("https://example.net/")}, &url.URL{Scheme: "https", Host: "example.net", Path: "/"}, false},
{"invalid", args{int(100)}, nil, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotU, err := ToURLE(tt.args.i)
if (err != nil) != tt.wantErr {
t.Errorf("ToURLE() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(gotU, tt.wantU) {
t.Errorf("ToURLE() = %v, want %v", gotU, tt.wantU)
}
})
}
}

Loading…
Cancel
Save