-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_test.go
More file actions
45 lines (41 loc) · 967 Bytes
/
client_test.go
File metadata and controls
45 lines (41 loc) · 967 Bytes
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
package vcdusage_test
import (
"fmt"
"net/url"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.stellar.af/go-vcdusage"
)
func Test_New(t *testing.T) {
u, err := vcdusage.ParseURL(Env.URL)
require.NoError(t, err)
_, err = vcdusage.New(
vcdusage.Insecure(),
vcdusage.URL(u),
vcdusage.Username(Env.Username),
vcdusage.Password(Env.Password),
)
require.NoError(t, err)
}
func Test_ParseURL(t *testing.T) {
cases := []string{
"vcd.example.com",
"vcd.example.com/api",
"http://vcd.example.com",
"http://vcd.example.com/api",
"https://vcd.example.com",
"https://vcd.example.com/api",
}
final, err := url.Parse("https://vcd.example.com/api")
require.NoError(t, err)
for i := 0; i < len(cases); i++ {
us := cases[i]
t.Run(fmt.Sprintf("%d-%s", i+1, us), func(t *testing.T) {
t.Parallel()
u, err := vcdusage.ParseURL(us)
require.NoError(t, err)
assert.Equal(t, final, u)
})
}
}