Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom user configuration in integration tests #106

Open
bluek1te opened this issue Oct 24, 2022 · 1 comment
Open

Support custom user configuration in integration tests #106

bluek1te opened this issue Oct 24, 2022 · 1 comment

Comments

@bluek1te
Copy link

bluek1te commented Oct 24, 2022

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!)
@marco-m-pix4d
Copy link
Contributor

marco-m-pix4d commented Oct 26, 2022

Hello @bluek1te,
yes, this is indeed finishing what I left half done :-)
The only caveat is that it should work also under GitHub Actions, without gopass, by reading secrets injected in the GH Actions UI. I am mentioning this because I forgot the details.
Please proceed with a PR, we will add fixes (if needed) there.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants