-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #435 from CircleCI-Public/validate-token
Validate that a circle token has been set before running context commands
- Loading branch information
Showing
3 changed files
with
66 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package cmd_test | ||
|
||
import ( | ||
"os/exec" | ||
|
||
"github.com/CircleCI-Public/circleci-cli/clitest" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
"github.com/onsi/gomega/gbytes" | ||
"github.com/onsi/gomega/gexec" | ||
) | ||
|
||
var _ = Describe("Context integration tests", func() { | ||
Describe("when listing contexts without a token", func() { | ||
var ( | ||
command *exec.Cmd | ||
tempSettings *clitest.TempSettings | ||
) | ||
|
||
BeforeEach(func() { | ||
tempSettings = clitest.WithTempSettings() | ||
command = commandWithHome(pathCLI, tempSettings.Home, | ||
"context", "list", "github", "foo", | ||
"--skip-update-check", | ||
"--token", "", | ||
) | ||
}) | ||
|
||
It("instructs the user to run 'circleci setup' and create a new token", func() { | ||
By("running the command") | ||
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter) | ||
|
||
Expect(err).ShouldNot(HaveOccurred()) | ||
Eventually(session.Err).Should(gbytes.Say(`Error: please set a token with 'circleci setup' | ||
You can create a new personal API token here: | ||
https://circleci.com/account/api`)) | ||
Eventually(session).Should(clitest.ShouldFail()) | ||
}) | ||
}) | ||
|
||
// TODO: add integration tests for happy path cases | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
# Aruba reference | ||
# https://gist.github.com/bdunn313/4199906 | ||
|
||
Feature: Context integration tests | ||
|
||
@mocked_home_directory | ||
Scenario: when listing contexts without a token | ||
When I run `circleci context list github foo --skip-update-check --token ""` | ||
Then the output should contain: | ||
""" | ||
Error: please set a token with 'circleci setup' | ||
You can create a new personal API token here: | ||
https://circleci.com/account/api | ||
""" | ||
And the exit status should be 255 |