Skip to content

Commit

Permalink
test: Added test for compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesFaucherre committed May 10, 2023
1 parent f6c133c commit 4e67cd2
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions cmd/orb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,77 @@ See a full explanation and documentation on orbs here: https://circleci.com/docs
})
})

Describe("with old server version", func() {
BeforeEach(func() {
token = "testtoken"
command = exec.Command(pathCLI,
"orb", "validate",
"--skip-update-check",
"--token", token,
"--host", tempSettings.TestServer.URL(),
"-",
)
stdin, err := command.StdinPipe()
Expect(err).ToNot(HaveOccurred())
go func() {
defer stdin.Close()
_, err := io.WriteString(stdin, "{}")
if err != nil {
panic(err)
}
}()
})

It("should use the old GraphQL resolver", func() {
By("setting up a mock server")

mockOrbIntrospection(false, "", tempSettings)

gqlResponse := `{
"orbConfig": {
"sourceYaml": "{}",
"valid": true,
"errors": []
}
}`

response := struct {
Query string `json:"query"`
Variables struct {
Config string `json:"config"`
} `json:"variables"`
}{
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())

tempSettings.AppendPostHandler(token, clitest.MockRequestResponse{
Status: http.StatusOK,
Request: string(expected),
Response: gqlResponse})

session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)

Expect(err).ShouldNot(HaveOccurred())
Eventually(session.Out).Should(gbytes.Say("Orb input is valid."))
Eventually(session).Should(gexec.Exit(0))
})
})

Context("with 'some orb'", func() {
BeforeEach(func() {
orb.Write([]byte(`some orb`))
Expand Down

0 comments on commit 4e67cd2

Please sign in to comment.