-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathinit_test.go
More file actions
77 lines (57 loc) · 1.62 KB
/
Copy pathinit_test.go
File metadata and controls
77 lines (57 loc) · 1.62 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package integration_test
import (
"fmt"
"os"
"testing"
"github.com/robdimsdale/sanitizer"
"github.com/pivotal-cf/go-pivnet/v9"
"github.com/pivotal-cf/go-pivnet/v9/logger"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
const testProductSlug = "pivnet-resource-test"
var client pivnet.Client
func TestIntegration(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Integration Suite")
}
var _ = BeforeSuite(func() {
APIToken := os.Getenv("API_TOKEN")
Host := os.Getenv("HOST")
if APIToken == "" {
Fail("API_TOKEN must be set for integration tests to run")
}
if Host == "" {
Fail("HOST must be set for integration tests to run")
}
By("Sanitizing acceptance test output")
sanitized := map[string]string{
APIToken: "***sanitized-api-token***",
}
sanitizedWriter := sanitizer.NewSanitizer(sanitized, GinkgoWriter)
GinkgoWriter = sanitizedWriter
accessTokenService := pivnet.NewAccessTokenOrLegacyToken(APIToken, Host, false)
config := pivnet.ClientConfig{
Host: Host,
UserAgent: "go-pivnet/integration-test",
}
logger := GinkgoLogShim{}
client = pivnet.NewClient(accessTokenService, config, logger)
ok, err := client.Auth.Check()
Expect(err).NotTo(HaveOccurred())
Expect(ok).To(BeTrue())
})
type GinkgoLogShim struct {
}
func (l GinkgoLogShim) Debug(action string, data ...logger.Data) {
l.Info(action, data...)
}
func (l GinkgoLogShim) Info(action string, data ...logger.Data) {
GinkgoWriter.Write([]byte(fmt.Sprintf("%s%s\n", action, appendString(data...))))
}
func appendString(data ...logger.Data) string {
if len(data) > 0 {
return fmt.Sprintf(" - %+v", data)
}
return ""
}