From 477fcf62e473701a4139d8871c1e0f018e39d865 Mon Sep 17 00:00:00 2001 From: Jay McCure Date: Wed, 26 Apr 2023 14:54:10 +1000 Subject: [PATCH] test: add instructions for testing against GDK --- CONTRIBUTING.md | 16 ++++++++++++++++ .../issue_subscribe_integration_test.go | 2 -- .../issue_unsubscribe_integration_test.go | 2 -- .../update/issue_update_integration_test.go | 2 -- test/helpers.go | 9 +++++++++ 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 95bd1a1a6..3307524bf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,6 +58,22 @@ Integration tests use the `_Integration` test suffix and use the `_integration_t `GITLAB_TOKEN` must be a [personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html). +### Running integration tests against the GDK + +For local development, the integration tests can be configured to run against an arbitrary GitLab instance, including an instance of the [GDK](https://gitlab.com/gitlab-org/gitlab-development-kit). + +Depending on what tests are to be executed, test data may need to be created in the instance or IDs may need to be altered in the tests. +In CI the integration tests use the [cli-automated-testing/test](https://gitlab.com/cli-automated-testing/test) repository. + +Additional environment variables may have to be set: +`GITLAB_TEST_API_PROTOCOL` - set if the instance does not use `https` +`GITLAB_TEST_API_HOST` - set when the `api_host` is different to the `host` + +Example command: +```shell +GITLAB_TEST_API_HOST="192.168.4.31:3000" GITLAB_TEST_API_PROTOCOL=http GITLAB_TEST_HOST="http://192.168.4.31" GITLAB_TOKEN=XXX make test +``` + ### Submitting a merge request 1. Create a new branch: `git checkout -b my-branch-name` diff --git a/commands/issue/subscribe/issue_subscribe_integration_test.go b/commands/issue/subscribe/issue_subscribe_integration_test.go index a1ca8d7e4..f5416cc77 100644 --- a/commands/issue/subscribe/issue_subscribe_integration_test.go +++ b/commands/issue/subscribe/issue_subscribe_integration_test.go @@ -19,8 +19,6 @@ import ( func TestNewCmdSubscribe_Integration(t *testing.T) { glTestHost := test.GetHostOrSkip(t) - t.Parallel() - oldSubscribeIssue := api.SubscribeToIssue timer, _ := time.Parse(time.RFC3339, "2014-11-12T11:45:26.371Z") api.SubscribeToIssue = func(client *gitlab.Client, projectID interface{}, issueID int, opts gitlab.RequestOptionFunc) (*gitlab.Issue, error) { diff --git a/commands/issue/unsubscribe/issue_unsubscribe_integration_test.go b/commands/issue/unsubscribe/issue_unsubscribe_integration_test.go index 2e919a7ec..a6ef09424 100644 --- a/commands/issue/unsubscribe/issue_unsubscribe_integration_test.go +++ b/commands/issue/unsubscribe/issue_unsubscribe_integration_test.go @@ -19,8 +19,6 @@ import ( func TestNewCmdUnsubscribe_Integration(t *testing.T) { glTestHost := test.GetHostOrSkip(t) - t.Parallel() - oldUnsubscribeIssue := api.UnsubscribeFromIssue timer, _ := time.Parse(time.RFC3339, "2014-11-12T11:45:26.371Z") api.UnsubscribeFromIssue = func(client *gitlab.Client, projectID interface{}, issueID int, opts gitlab.RequestOptionFunc) (*gitlab.Issue, error) { diff --git a/commands/issue/update/issue_update_integration_test.go b/commands/issue/update/issue_update_integration_test.go index 1d10f3eb5..4665e3d32 100644 --- a/commands/issue/update/issue_update_integration_test.go +++ b/commands/issue/update/issue_update_integration_test.go @@ -23,8 +23,6 @@ import ( func TestNewCmdUpdate_Integration(t *testing.T) { glTestHost := test.GetHostOrSkip(t) - t.Parallel() - oldUpdateIssue := api.UpdateIssue timer, _ := time.Parse(time.RFC3339, "2014-11-12T11:45:26.371Z") testIssue := &gitlab.Issue{ diff --git a/test/helpers.go b/test/helpers.go index 6ccf172b8..3ba5e193c 100644 --- a/test/helpers.go +++ b/test/helpers.go @@ -115,5 +115,14 @@ func GetHostOrSkip(t testing.TB) string { } t.Skip("Set GITLAB_TEST_HOST and GITLAB_TOKEN to run this integration test") } + + if os.Getenv("GITLAB_TEST_API_PROTOCOL") != "" { + t.Setenv("API_PROTOCOL", os.Getenv("GITLAB_TEST_API_PROTOCOL")) + } + + if os.Getenv("GITLAB_TEST_API_HOST") != "" { + t.Setenv("GITLAB_API_HOST", os.Getenv("GITLAB_TEST_API_HOST")) + } + return glTestHost } -- GitLab