/
testing.go
55 lines (44 loc) · 1.28 KB
/
testing.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
package scalr
import (
"fmt"
"os"
"reflect"
"testing"
"github.com/scalr/go-scalr"
)
const defaultAccount = "acc-svrcncgh453bi8g"
const testUser = "user-suh84u6vuvidtbg" // test@scalr.com
const testUserEmail = "test@scalr.com"
const readOnlyRole = "role-t67mjtmabulckto" // Reader
const userRole = "role-t67mjtmauajto7g" // User
func testScalrClient(t *testing.T) *scalr.Client {
config := &scalr.Config{
Token: "not-a-token",
}
client, err := scalr.NewClient(config)
if err != nil {
t.Fatalf("error creating Scalr client: %v", err)
}
client.Workspaces = newMockWorkspaces()
client.Variables = newMockVariables()
return client
}
func assertCorrectState(t *testing.T, err error, actual, expected map[string]interface{}) {
t.Helper()
if err != nil {
t.Fatalf("error migrating state: %s", err)
}
if !reflect.DeepEqual(expected, actual) {
t.Fatalf("\n\nexpected:\n\n%#v\n\ngot:\n\n%#v\n\n", expected, actual)
}
}
// isAccTest returns true if executed while running acceptance tests
func isAccTest() bool {
return os.Getenv("TF_ACC") == "1"
}
func createScalrClient() (*scalr.Client, error) {
config := scalr.DefaultConfig()
config.Address = fmt.Sprintf("https://%s", os.Getenv("SCALR_HOSTNAME"))
scalrClient, err := scalr.NewClient(config)
return scalrClient, err
}