cogito
cogito copied to clipboard
Support custom user configuration in integration tests
Hello,
As I was going through CONTRIBUTING.md to run the integration tests, and I modified the tasks.yml to input my own values from gopass into task test:env -- task test:all
. I was wondering if it would be possible to open a PR to merge these changes.
Ex:
+++ b/Taskfile.yml
@@ -48,13 +48,16 @@ tasks:
cmds:
- '{{ .CLI_ARGS }}'
env: &test-env
- COGITO_TEST_COMMIT_SHA: '{{default "32e4b4f91bb8de500f6a7aa2011f93c3f322381c" .COGITO_TEST_COMMIT_SHA}}'
+ COGITO_TEST_COMMIT_SHA:
+ sh: 'echo -n {{default "$(gopass show cogito/test_commit_sha)" .COGITO_TEST_COMMIT_SHA}}'
COGITO_TEST_OAUTH_TOKEN:
- sh: 'echo {{default "$(gopass show cogito/test_oauth_token)" .COGITO_TEST_OAUTH_TOKEN}}'
- COGITO_TEST_REPO_NAME: '{{default "cogito-test-read-write" .COGITO_TEST_REPO_NAME}}'
- COGITO_TEST_REPO_OWNER: '{{default "pix4d" .COGITO_TEST_REPO_OWNER}}'
+ sh: 'echo -n {{default "$(gopass show cogito/test_oauth_token)" .COGITO_TEST_OAUTH_TOKEN}}'
+ COGITO_TEST_REPO_NAME:
+ sh: 'echo -n {{default "$(gopass show cogito/test_repo_name)" .COGITO_TEST_REPO_NAME}}'
+ COGITO_TEST_REPO_OWNER:
+ sh: 'echo -n {{default "$(gopass show cogito/test_repo_owner)" .COGITO_TEST_REPO_OWNER}}'
COGITO_TEST_GCHAT_HOOK:
- sh: 'echo {{default "$(gopass show cogito/test_gchat_webhook)" .COGITO_TEST_GCHAT_HOOK}}'
+ sh: 'echo -n {{default "$(gopass show cogito/test_gchat_webhook)" .COGITO_TEST_GCHAT_HOOK}}'
--- a/github/commitstatus_test.go
+++ b/github/commitstatus_test.go
@@ -168,34 +168,34 @@ func TestGitHubStatusFailureIntegration(t *testing.T) {
{
name: "bad token: Unauthorized",
token: "bad-token",
- wantErr: `failed to add state "success" for commit 32e4b4f: 401 Unauthorized
+ wantErr: fmt.Sprintf(`failed to add state "success" for commit %s: 401 Unauthorized
Body: {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest"}
Hint: Either wrong credentials or PAT expired (check your email for expiration notice)
-Action: POST https://api.github.com/repos/pix4d/cogito-test-read-write/statuses/32e4b4f91bb8de500f6a7aa2011f93c3f322381c
-OAuth: X-Accepted-Oauth-Scopes: [], X-Oauth-Scopes: []`,
+Action: POST https://api.github.com/repos/%s/%s/statuses/%s
+OAuth: X-Accepted-Oauth-Scopes: [], X-Oauth-Scopes: []`, cfg.SHA[0:7], cfg.Owner, cfg.Repo, cfg.SHA),```
(If this was already possible to do, but I ran the commands incorrectly, please let me know, thanks!)