-
Notifications
You must be signed in to change notification settings - Fork 0
/
synpse_test.go
70 lines (54 loc) · 1.94 KB
/
synpse_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
package synpse
import (
"os"
"testing"
"github.com/stretchr/testify/require"
)
const (
EnvSynpseAPIEndpointURL = "SYNPSE_API_ENDPOINT_URL"
EnvSynpsePersonalAccessKey = "SYNPSE_PERSONAL_ACCESS_KEY"
EnvSynpseProjectAccessKey = "SYNPSE_PROJECT_ACCESS_KEY"
EnvSynpseSDKTestProjectName = "SYNPSE_SDK_TEST_PROJECT_NAME"
EnvSynpseSDKTestProjectID = "SYNPSE_SDK_TEST_PROJECT_ID"
EnvSynpseSDKTestApplicationName = "SYNPSE_SDK_TEST_APPLICATION_NAME"
)
// Testing data
var (
sdkTestProjectName string
sdkTestProjectID string
sdkTestApplicationName string
sdkTestNamespace = "default"
)
func init() {
sdkTestProjectName = os.Getenv(EnvSynpseSDKTestProjectName)
sdkTestProjectID = os.Getenv(EnvSynpseSDKTestProjectID)
sdkTestApplicationName = os.Getenv(EnvSynpseSDKTestApplicationName)
}
// getTestingClient returns a new API client for testing purposes. This
// client should be using project access keys.
func getTestingProjectClient(t *testing.T) *API {
apiEndpointURL := os.Getenv(EnvSynpseAPIEndpointURL)
accessKey := os.Getenv(EnvSynpseProjectAccessKey)
projectID := os.Getenv(EnvSynpseSDKTestProjectID)
var opts []Option
if apiEndpointURL != "" {
opts = append(opts, WithAPIEndpointURL(apiEndpointURL))
}
apiClient, err := NewWithProject(accessKey, projectID, opts...)
require.NoError(t, err, "failed to create API client")
return apiClient
}
// getTestingPersonalClient returns a new API client for testing purposes. This
// client should be using personal access keys.
func getTestingPersonalClient(t *testing.T) *API {
apiEndpointURL := os.Getenv(EnvSynpseAPIEndpointURL)
accessKey := os.Getenv(EnvSynpsePersonalAccessKey)
projectID := os.Getenv(EnvSynpseSDKTestProjectID)
var opts []Option
if apiEndpointURL != "" {
opts = append(opts, WithAPIEndpointURL(apiEndpointURL))
}
apiClient, err := NewWithProject(accessKey, projectID, opts...)
require.NoError(t, err, "failed to create API client")
return apiClient
}