Skip to content

Commit

Permalink
Add integration test for dependency specifiers.
Browse files Browse the repository at this point in the history
- vendor robdimsdale/sanitizer for integration test.

[#135856239]
  • Loading branch information
robdimsdale committed Dec 26, 2016
1 parent 6ee0f40 commit e9d5824
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 2 deletions.
80 changes: 80 additions & 0 deletions integration/dependency_specifiers_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package integration_test

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
pivnet "github.com/pivotal-cf/go-pivnet"
)

const (
dependentProductSlug = "stemcells"
specifier = "3312.*"
)

var _ = Describe("Dependency Specifier Integration", func() {
var (
newRelease pivnet.Release
)

BeforeEach(func() {
var err error
newRelease, err = client.Releases.Create(pivnet.CreateReleaseConfig{
ProductSlug: testProductSlug,
Version: "some-test-version",
ReleaseType: "Beta Release",
EULASlug: "pivotal_beta_eula",
})
Expect(err).NotTo(HaveOccurred())
})

AfterEach(func() {
err := client.Releases.Delete(testProductSlug, newRelease)
Expect(err).NotTo(HaveOccurred())
})

It("creates, lists, and deletes dependency specifiers", func() {
By("Listing dependency specifiers")
dependencySpecifiers, err := client.DependencySpecifiers.List(testProductSlug, newRelease.ID)
Expect(err).NotTo(HaveOccurred())

By("Creating new dependency specifier")
dependencySpecifier, err := client.DependencySpecifiers.Create(
testProductSlug,
newRelease.ID,
dependentProductSlug,
specifier,
)
Expect(err).NotTo(HaveOccurred())

Expect(dependencySpecifiers).ShouldNot(ContainElement(dependencySpecifier))

By("Re-listing dependency specifiers")
updatedDependencySpecifiers, err := client.DependencySpecifiers.List(testProductSlug, newRelease.ID)
Expect(err).NotTo(HaveOccurred())

Expect(updatedDependencySpecifiers).Should(ContainElement(dependencySpecifier))

By("Getting individual dependency specifier")
individualDependencySpecifier, err := client.DependencySpecifiers.Get(
testProductSlug,
newRelease.ID,
dependencySpecifier.ID,
)
Expect(err).NotTo(HaveOccurred())

Expect(individualDependencySpecifier).To(Equal(dependencySpecifier))

By("Deleting dependency specifier")
err = client.DependencySpecifiers.Delete(
testProductSlug,
newRelease.ID,
dependencySpecifier.ID,
)
Expect(err).NotTo(HaveOccurred())

newlyUpdatedDependencySpecifiers, err := client.DependencySpecifiers.List(testProductSlug, newRelease.ID)
Expect(err).NotTo(HaveOccurred())

Expect(newlyUpdatedDependencySpecifiers).ShouldNot(ContainElement(dependencySpecifier))
})
})
31 changes: 29 additions & 2 deletions integration/init_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package integration_test

import (
"fmt"
"os"

"github.com/pivotal-cf/go-pivnet"
"github.com/pivotal-cf/go-pivnet/logger/loggerfakes"
"github.com/pivotal-cf/go-pivnet/logger"
"github.com/robdimsdale/sanitizer"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -33,17 +35,42 @@ var _ = BeforeSuite(func() {
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

config := pivnet.ClientConfig{
Host: Host,
Token: APIToken,
UserAgent: "go-pivnet/integration-test",
}

logger := &loggerfakes.FakeLogger{}
logger := GinkgoLogShim{}

client = pivnet.NewClient(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 ""
}
21 changes: 21 additions & 0 deletions vendor/github.com/robdimsdale/sanitizer/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions vendor/github.com/robdimsdale/sanitizer/sanitizer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions vendor/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@
"branch": "master",
"notests": true
},
{
"importpath": "github.com/robdimsdale/sanitizer",
"repository": "https://github.com/robdimsdale/sanitizer",
"vcs": "git",
"revision": "ab2334cb7539a2ce27b7aea53b7d693087b10cd9",
"branch": "master",
"notests": true
},
{
"importpath": "golang.org/x/net/context",
"repository": "https://go.googlesource.com/net",
Expand Down

0 comments on commit e9d5824

Please sign in to comment.