diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 95bd1a1a682a94358c99d59e5be3aa17764b466a..3307524bf14e97a7a64599cb616617303fc84e03 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 a1ca8d7e4a886c8abbc803827f0c73c3e05a5cd6..f5416cc77002b57de80c1710b4730d0e33399af5 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 2e919a7ec52b89f8f173c65a5198ea5c434b795b..a6ef094244627eed017455445428df74000c60a2 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 1d10f3eb5ce78bed6be4835e24e5672903904012..4665e3d32eae269d95fc5c2d0a3804e04a6f2c14 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 6ccf172b882c763b77e2b4977632eefc66851407..3ba5e193ccba96cc075519620058b0d1e832e2b4 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 }