-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathoptions_test.go
More file actions
55 lines (41 loc) · 1.27 KB
/
Copy pathoptions_test.go
File metadata and controls
55 lines (41 loc) · 1.27 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package stackit
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestMissingBaseURL(t *testing.T) {
t.Parallel()
options, err := SetConfigOptions("", "", "", "")
assert.ErrorContains(t, err, "base-url")
assert.Nil(t, options)
}
func TestBothAuthOptionsMissing(t *testing.T) {
t.Parallel()
options, err := SetConfigOptions("https://example.com", "", "", "")
assert.ErrorContains(t, err, "auth-token or auth-key-path")
assert.Nil(t, options)
}
func TestBothAuthOptionsSet(t *testing.T) {
t.Parallel()
options, err := SetConfigOptions("https://example.com", "token", "key/path", "")
assert.ErrorContains(t, err, "auth-token or auth-key-path")
assert.Nil(t, options)
}
func TestBearerTokenSet(t *testing.T) {
t.Parallel()
options, err := SetConfigOptions("https://example.com", "token", "", "")
assert.NoError(t, err)
assert.Len(t, options, 3)
}
func TestKeyPathSet(t *testing.T) {
t.Parallel()
options, err := SetConfigOptions("https://example.com", "", "key/path", "")
assert.NoError(t, err)
assert.Len(t, options, 4)
}
func TestKeyPathAndURLSet(t *testing.T) {
t.Parallel()
options, err := SetConfigOptions("https://example.com", "", "key/path", "https://alternative.url.stackit.cloud/token")
assert.NoError(t, err)
assert.Len(t, options, 5)
}