-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudinary_test.go
More file actions
37 lines (35 loc) · 1.02 KB
/
cloudinary_test.go
File metadata and controls
37 lines (35 loc) · 1.02 KB
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
package cloudinary
import (
"reflect"
"testing"
)
func TestNew(t *testing.T) {
type args struct {
uri string
}
tests := []struct {
name string
args args
want *Cloudinary
wantErr bool
}{
{"without scheme", args{"apikey:apisecret@cloudname"}, nil, true},
{"with wrong scheme", args{"wrongscheme://apikey:apisecret@cloudname"}, nil, true},
{"without cloudname", args{"cloudinary://apikey:apisecret@"}, nil, true},
{"without apikey", args{"cloudinary://:apisecret@cloudname"}, nil, true},
{"without secret", args{"cloudinary://apikey:@cloudname"}, nil, true},
{"with good params", args{"cloudinary://apikey:apisecret@cloudname"}, &Cloudinary{"cloudname", "apikey", "apisecret"}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := New(tt.args.uri)
if (err != nil) != tt.wantErr {
t.Errorf("New() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("New() = %v, want %v", got, tt.want)
}
})
}
}