Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Commit

Permalink
add graphql api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
laverya committed Jun 15, 2018
1 parent 9754a22 commit 9391f67
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 2 deletions.
1 change: 1 addition & 0 deletions integration/basic-stateless/channel_id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
QzNurgwRPG9dH6FpHJx7iyEPklSNI7fP
File renamed without changes.
1 change: 1 addition & 0 deletions integration/basic-stateless/installation_id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jcmvgHoBCkKPfqM9Qp-iDJCMlDSgyT6L
1 change: 1 addition & 0 deletions integration/basic-stateless/release_version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.3
1 change: 1 addition & 0 deletions integration/basic/channel_id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
QzNurgwRPG9dH6FpHJx7iyEPklSNI7fP
1 change: 1 addition & 0 deletions integration/basic/installation_id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jcmvgHoBCkKPfqM9Qp-iDJCMlDSgyT6L
1 change: 1 addition & 0 deletions integration/basic/release_version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.3
44 changes: 42 additions & 2 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,29 @@ var _ = Describe("basic", func() {
testOutputPath := path.Join(testPath, "tmp")
testInputPath := path.Join(testPath, "input")

idBytes, err := ioutil.ReadFile(path.Join(testPath, "customer_id"))
custIdBytes, err := ioutil.ReadFile(path.Join(testPath, "customer_id"))
if err != nil {
panic(err)
}
customerId := string(idBytes)
customerId := string(custIdBytes)

installationIdBytes, err := ioutil.ReadFile(path.Join(testPath, "installation_id"))
if err != nil {
panic(err)
}
installationId := string(installationIdBytes)

channelIdBytes, err := ioutil.ReadFile(path.Join(testPath, "channel_id"))
if err != nil {
panic(err)
}
channelId := string(channelIdBytes)

releaseVersionBytes, err := ioutil.ReadFile(path.Join(testPath, "release_version"))
if err != nil {
panic(err)
}
releaseVersion := string(releaseVersionBytes)

BeforeEach(func() {
//create a temporary directory within this directory to compare files with
Expand Down Expand Up @@ -126,9 +144,31 @@ var _ = Describe("basic", func() {
"--headless",
fmt.Sprintf("--studio-file=%s", path.Join(testInputPath, ".ship/release.yml")),
fmt.Sprintf("--state-file=%s", path.Join(testInputPath, ".ship/state.json")),
"--log-level=off",
}))
err := cmd.Execute()
Expect(err).NotTo(HaveOccurred())

//compare the files in the temporary directory with those in the "expected" directory
result, err := CompareDir(path.Join(testPath, "expected"), testOutputPath)
Expect(err).NotTo(HaveOccurred())
Expect(result).To(BeTrue())

}, 60)

It("Should output files matching those expected when communicating with the graphql api", func() {
cmd := cli.RootCmd()
buf := new(bytes.Buffer)
cmd.SetOutput(buf)
cmd.SetArgs(append([]string{
"--headless",
fmt.Sprintf("--state-file=%s", path.Join(testInputPath, ".ship/state.json")),
"--customer-endpoint=https://pg.staging.replicated.com/graphql",
"--log-level=off",
fmt.Sprintf("--customer-id=%s", customerId),
fmt.Sprintf("--installation-id=%s", installationId),
fmt.Sprintf("--channel-id=%s", channelId),
fmt.Sprintf("--release-semver=%s", releaseVersion),
}))
err := cmd.Execute()
Expect(err).NotTo(HaveOccurred())
Expand Down

0 comments on commit 9391f67

Please sign in to comment.