-
Notifications
You must be signed in to change notification settings - Fork 3
/
provider_configuration_link_test.go
117 lines (90 loc) · 3.19 KB
/
provider_configuration_link_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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package scalr
import (
"context"
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestProviderConfigurationLinkCreate(t *testing.T) {
client := testClient(t)
ctx := context.Background()
t.Run("workspace link", func(t *testing.T) {
environment, removeEnvironment := createEnvironment(t, client)
defer removeEnvironment()
configuration, deleteConfiguration := createProviderConfiguration(
t, client, "kubernetes", "kubernetes_dev",
)
defer deleteConfiguration()
workspace, deleteWorkspace := createWorkspace(t, client, environment)
defer deleteWorkspace()
createLinkOptions := ProviderConfigurationLinkCreateOptions{
ProviderConfiguration: configuration,
Alias: String("dev"),
}
workspaceLink, err := client.ProviderConfigurationLinks.Create(
ctx, workspace.ID, createLinkOptions,
)
require.NoError(t, err)
workspaceLink, err = client.ProviderConfigurationLinks.Read(ctx, workspaceLink.ID)
require.NoError(t, err)
assert.Equal(t, *createLinkOptions.Alias, workspaceLink.Alias)
})
}
func TestProviderConfigurationLinkUpdate(t *testing.T) {
client := testClient(t)
ctx := context.Background()
configuration, deleteConfiguration := createProviderConfiguration(
t, client, "kubernetes", "kubernetes_dev",
)
defer deleteConfiguration()
environment, removeEnvironment := createEnvironment(t, client)
defer removeEnvironment()
workspace, deleteWorkspace := createWorkspace(t, client, environment)
defer deleteWorkspace()
t.Run("workspace link", func(t *testing.T) {
createOptions := ProviderConfigurationLinkCreateOptions{
Alias: String("dev"), ProviderConfiguration: configuration,
}
workspacelink, err := client.ProviderConfigurationLinks.Create(
ctx, workspace.ID, createOptions,
)
require.NoError(t, err)
updateOptions := ProviderConfigurationLinkUpdateOptions{Alias: String("demo")}
workspacelink, err = client.ProviderConfigurationLinks.Update(ctx, workspacelink.ID, updateOptions)
require.NoError(t, err)
assert.Equal(t, *updateOptions.Alias, workspacelink.Alias)
})
}
func TestProviderConfigurationLinkDelete(t *testing.T) {
client := testClient(t)
ctx := context.Background()
environment, removeEnvironment := createEnvironment(t, client)
defer removeEnvironment()
workspace, deleteWorkspace := createWorkspace(t, client, environment)
defer deleteWorkspace()
configuration, deleteConfiguration := createProviderConfiguration(
t, client, "kubernetes", "kubernetes_dev",
)
defer deleteConfiguration()
t.Run("success", func(t *testing.T) {
options := ProviderConfigurationLinkCreateOptions{
Alias: String("dev"), ProviderConfiguration: configuration,
}
link, err := client.ProviderConfigurationLinks.Create(
ctx, workspace.ID, options,
)
require.NoError(t, err)
err = client.ProviderConfigurationLinks.Delete(ctx, link.ID)
require.NoError(t, err)
// Try loading the configuration - it should fail.
_, err = client.ProviderConfigurationLinks.Read(ctx, link.ID)
assert.Equal(
t,
ResourceNotFoundError{
Message: fmt.Sprintf("ProviderConfigurationLink with ID '%s' not found or user unauthorized.", link.ID),
}.Error(),
err.Error(),
)
})
}