Skip to content

Commit

Permalink
Clean up expected json response data and match formatting from API
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Scott committed Jul 23, 2018
1 parent 436d7bb commit ca96a7f
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions cmd/orb_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package cmd_test

import (
"encoding/json"
"net/http"
"os/exec"
"path/filepath"

"io"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
"github.com/onsi/gomega/ghttp"
"io"
)

var _ = Describe("Orb", func() {
Expand Down Expand Up @@ -66,14 +68,33 @@ var _ = Describe("Orb", func() {
}
}`

expectedRequestJson := ` {
"query": "\n\t\tquery ValidateOrb ($config: String!) {\n\t\t\torbConfig(orbYaml: $config) {\n\t\t\t\tvalid,\n\t\t\t\terrors { message },\n\t\t\t\tsourceYaml,\n\t\t\t\toutputYaml\n\t\t\t}\n\t\t}",
"variables": {
"config": "{}"
}
}`
type requestJson struct {
Query string `json:"query"`
Variables struct {
Config string `json:"config"`
} `json:"variables"`
}

response := requestJson{
Query: `
query ValidateOrb ($config: String!) {
orbConfig(orbYaml: $config) {
valid,
errors { message },
sourceYaml,
outputYaml
}
}`,
Variables: struct {
Config string `json:"config"`
}{
Config: "{}",
},
}
expected, err := json.Marshal(response)
Expect(err).ShouldNot(HaveOccurred())

appendPostHandler(testServer, token, http.StatusOK, expectedRequestJson, gqlResponse)
appendPostHandler(testServer, token, http.StatusOK, string(expected), gqlResponse)
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)

Expect(err).ShouldNot(HaveOccurred())
Expand Down

0 comments on commit ca96a7f

Please sign in to comment.