Skip to content

Commit

Permalink
Rename ns to namespace (to opaque as ns) and add a description
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Scott committed Jul 31, 2018
1 parent 0bce99e commit 844a4cf
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/orb.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,16 @@ func newOrbCommand() *cobra.Command {
createNamespace.PersistentFlags().StringVar(&organizationVcs, "vcs", "github", "organization vcs, e.g. 'github', 'bitbucket'")

namespaceCommand := &cobra.Command{
Use: "ns",
Use: "namespace",
Short: "Operate on orb namespaces (create, etc.)",
}
namespaceCommand.AddCommand(createNamespace)
nsCommand := &cobra.Command{
Use: "ns",
Short: "Operate on orb namespaces (create, etc.)",
Hidden: true,
}
nsCommand.AddCommand(createNamespace)

orbCommand := &cobra.Command{
Use: "orb",
Expand All @@ -105,6 +111,7 @@ func newOrbCommand() *cobra.Command {
orbCommand.AddCommand(publishCommand)

orbCommand.AddCommand(namespaceCommand)
orbCommand.AddCommand(nsCommand)
orbCommand.AddCommand(sourceCommand)

return orbCommand
Expand Down
65 changes: 65 additions & 0 deletions cmd/orb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,71 @@ var _ = Describe("Orb integration tests", func() {
})
})

Describe("when using the full namespace command", func() {
BeforeEach(func() {
command = exec.Command(pathCLI,
"orb", "namespace", "create",
"-t", token,
"-e", testServer.URL(),
"foo-ns",
"--org-name", "test-org",
"--vcs", "BITBUCKET",
)
})

It("works with organizationName and organizationVcs", func() {
By("setting up a mock server")

gqlOrganizationResponse := `{
"organization": {
"name": "test-org",
"id": "bb604b45-b6b0-4b81-ad80-796f15eddf87"
}
}`

expectedOrganizationRequest := `{
"query": "\n\t\t\tquery($organizationName: String!, $organizationVcs: VCSType!) {\n\t\t\t\torganization(\n\t\t\t\t\tname: $organizationName\n\t\t\t\t\tvcsType: $organizationVcs\n\t\t\t\t) {\n\t\t\t\t\tid\n\t\t\t\t}\n\t\t\t}",
"variables": {
"organizationName": "test-org",
"organizationVcs": "BITBUCKET"
}
}`

gqlNsResponse := `{
"createNamespace": {
"errors": [],
"namespace": {
"id": "bb604b45-b6b0-4b81-ad80-796f15eddf87"
}
}
}`

expectedNsRequest := `{
"query": "\n\t\t\tmutation($name: String!, $organizationId: UUID!) {\n\t\t\t\tcreateNamespace(\n\t\t\t\t\tname: $name,\n\t\t\t\t\torganizationId: $organizationId\n\t\t\t\t) {\n\t\t\t\t\tnamespace {\n\t\t\t\t\t\tid\n\t\t\t\t\t}\n\t\t\t\t\terrors {\n\t\t\t\t\t\tmessage\n\t\t\t\t\t\ttype\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",
"variables": {
"name": "foo-ns",
"organizationId": "bb604b45-b6b0-4b81-ad80-796f15eddf87"
}
}`

appendPostHandler(testServer, token, MockRequestResponse{
Status: http.StatusOK,
Request: expectedOrganizationRequest,
Response: gqlOrganizationResponse})
appendPostHandler(testServer, token, MockRequestResponse{
Status: http.StatusOK,
Request: expectedNsRequest,
Response: gqlNsResponse})

By("running the command")
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)

Expect(err).ShouldNot(HaveOccurred())
Eventually(session.Out).Should(gbytes.Say("Namespace created"))
Eventually(session).Should(gexec.Exit(0))
})
})

Describe("when creating / reserving a namespace", func() {
BeforeEach(func() {
command = exec.Command(pathCLI,
Expand Down

0 comments on commit 844a4cf

Please sign in to comment.