Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-29 21:08:58 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-29 21:08:58 +0300
commita16398e10f87edd229a12be2f1fc87cd4a76f902 (patch)
treec3f4db5dbf36a8470689cab3ad3bfe55aced5f1d /spec/contracts
parent8c2d06cba79ff8965a4de9467e05e80d7c7f449e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/contracts')
-rw-r--r--spec/contracts/consumer/fixtures/project/pipeline/delete_pipeline.fixture.js19
-rw-r--r--spec/contracts/consumer/resources/graphql/pipelines.js21
-rw-r--r--spec/contracts/consumer/specs/project/pipeline/show.spec.js48
-rw-r--r--spec/contracts/contracts/project/pipeline/show/pipelines#show-delete_pipeline.json44
-rw-r--r--spec/contracts/provider/pact_helpers/project/pipeline/show/delete_pipeline_helper.rb16
-rw-r--r--spec/contracts/provider/pact_helpers/project/pipeline/show/get_pipeline_header_data_helper.rb (renamed from spec/contracts/provider/pact_helpers/project/pipeline/get_pipeline_header_data_helper.rb)4
-rw-r--r--spec/contracts/provider/states/project/pipeline/show_state.rb28
7 files changed, 174 insertions, 6 deletions
diff --git a/spec/contracts/consumer/fixtures/project/pipeline/delete_pipeline.fixture.js b/spec/contracts/consumer/fixtures/project/pipeline/delete_pipeline.fixture.js
new file mode 100644
index 00000000000..4dbb694064b
--- /dev/null
+++ b/spec/contracts/consumer/fixtures/project/pipeline/delete_pipeline.fixture.js
@@ -0,0 +1,19 @@
+const DeletePipeline = {
+ success: {
+ status: 200,
+ headers: {
+ 'Content-Type': 'application/json; charset=utf-8',
+ },
+ },
+
+ request: {
+ method: 'POST',
+ path: '/api/graphql',
+ },
+
+ variables: {
+ id: 'gid://gitlab/Ci::Pipeline/316112',
+ },
+};
+
+export { DeletePipeline };
diff --git a/spec/contracts/consumer/resources/graphql/pipelines.js b/spec/contracts/consumer/resources/graphql/pipelines.js
index 4f7ce58891c..b076006af17 100644
--- a/spec/contracts/consumer/resources/graphql/pipelines.js
+++ b/spec/contracts/consumer/resources/graphql/pipelines.js
@@ -23,3 +23,24 @@ export async function getPipelineHeaderDataRequest(endpoint) {
data: graphqlQuery,
});
}
+
+export async function deletePipeline(endpoint) {
+ const { url } = endpoint;
+ const query = await extractGraphQLQuery(
+ 'app/assets/javascripts/pipelines/graphql/mutations/delete_pipeline.mutation.graphql',
+ );
+ const graphqlQuery = {
+ query,
+ variables: {
+ id: 'gid://gitlab/Ci::Pipeline/316112',
+ },
+ };
+
+ return axios({
+ baseURL: url,
+ url: '/api/graphql',
+ method: 'POST',
+ headers: { Accept: '*/*' },
+ data: graphqlQuery,
+ });
+}
diff --git a/spec/contracts/consumer/specs/project/pipeline/show.spec.js b/spec/contracts/consumer/specs/project/pipeline/show.spec.js
index 0f1cc1c3108..2c5ba964e2e 100644
--- a/spec/contracts/consumer/specs/project/pipeline/show.spec.js
+++ b/spec/contracts/consumer/specs/project/pipeline/show.spec.js
@@ -6,24 +6,27 @@ import { GraphQLInteraction } from '@pact-foundation/pact';
import { extractGraphQLQuery } from '../../../helpers/graphql_query_extractor';
import { PipelineHeaderData } from '../../../fixtures/project/pipeline/get_pipeline_header_data.fixture';
-import { getPipelineHeaderDataRequest } from '../../../resources/graphql/pipelines';
+import { DeletePipeline } from '../../../fixtures/project/pipeline/delete_pipeline.fixture';
+
+import { getPipelineHeaderDataRequest, deletePipeline } from '../../../resources/graphql/pipelines';
const CONSUMER_NAME = 'Pipelines#show';
const CONSUMER_LOG = '../logs/consumer.log';
const CONTRACT_DIR = '../contracts/project/pipeline/show';
-const PROVIDER_NAME = 'GET pipeline header data';
+const GET_PIPELINE_HEADER_DATA_PROVIDER_NAME = 'GET pipeline header data';
+const DELETE_PIPELINE_PROVIDER_NAME = 'DELETE pipeline';
// GraphQL query: getPipelineHeaderData
pactWith(
{
consumer: CONSUMER_NAME,
- provider: PROVIDER_NAME,
+ provider: GET_PIPELINE_HEADER_DATA_PROVIDER_NAME,
log: CONSUMER_LOG,
dir: CONTRACT_DIR,
},
(provider) => {
- describe(PROVIDER_NAME, () => {
+ describe(GET_PIPELINE_HEADER_DATA_PROVIDER_NAME, () => {
beforeEach(async () => {
const query = await extractGraphQLQuery(
'app/assets/javascripts/pipelines/graphql/queries/get_pipeline_header_data.query.graphql',
@@ -50,4 +53,41 @@ pactWith(
},
);
+// GraphQL query: deletePipeline
+pactWith(
+ {
+ consumer: CONSUMER_NAME,
+ provider: DELETE_PIPELINE_PROVIDER_NAME,
+ log: CONSUMER_LOG,
+ dir: CONTRACT_DIR,
+ },
+
+ (provider) => {
+ describe(DELETE_PIPELINE_PROVIDER_NAME, () => {
+ beforeEach(async () => {
+ const query = await extractGraphQLQuery(
+ 'app/assets/javascripts/pipelines/graphql/mutations/delete_pipeline.mutation.graphql',
+ );
+ const graphqlQuery = new GraphQLInteraction()
+ .given('a pipeline for a project exists')
+ .uponReceiving('a request to delete the pipeline')
+ .withQuery(query)
+ .withRequest(DeletePipeline.request)
+ .withVariables(DeletePipeline.variables)
+ .willRespondWith(DeletePipeline.success);
+
+ provider.addInteraction(graphqlQuery);
+ });
+
+ it('returns a successful body', async () => {
+ const deletePipelineResponse = await deletePipeline({
+ url: provider.mockService.baseUrl,
+ });
+
+ expect(deletePipelineResponse.status).toEqual(DeletePipeline.success.status);
+ });
+ });
+ },
+);
+
/* eslint-enable @gitlab/require-i18n-strings */
diff --git a/spec/contracts/contracts/project/pipeline/show/pipelines#show-delete_pipeline.json b/spec/contracts/contracts/project/pipeline/show/pipelines#show-delete_pipeline.json
new file mode 100644
index 00000000000..795c8a6e197
--- /dev/null
+++ b/spec/contracts/contracts/project/pipeline/show/pipelines#show-delete_pipeline.json
@@ -0,0 +1,44 @@
+{
+ "consumer": {
+ "name": "Pipelines#show"
+ },
+ "provider": {
+ "name": "DELETE pipeline"
+ },
+ "interactions": [
+ {
+ "description": "a request to delete the pipeline",
+ "providerState": "a pipeline for a project exists",
+ "request": {
+ "method": "POST",
+ "path": "/api/graphql",
+ "headers": {
+ "content-type": "application/json"
+ },
+ "body": {
+ "query": "mutation deletePipeline($id: CiPipelineID!) {\n pipelineDestroy(input: { id: $id }) {\n errors\n }\n}\n",
+ "variables": {
+ "id": "gid://gitlab/Ci::Pipeline/316112"
+ }
+ },
+ "matchingRules": {
+ "$.body.query": {
+ "match": "regex",
+ "regex": "mutation\\s*deletePipeline\\(\\$id:\\s*CiPipelineID!\\)\\s*\\{\\s*pipelineDestroy\\(input:\\s*\\{\\s*id:\\s*\\$id\\s*\\}\\)\\s*\\{\\s*errors\\s*\\}\\s*\\}\\s*"
+ }
+ }
+ },
+ "response": {
+ "status": 200,
+ "headers": {
+ "Content-Type": "application/json; charset=utf-8"
+ }
+ }
+ }
+ ],
+ "metadata": {
+ "pactSpecification": {
+ "version": "2.0.0"
+ }
+ }
+} \ No newline at end of file
diff --git a/spec/contracts/provider/pact_helpers/project/pipeline/show/delete_pipeline_helper.rb b/spec/contracts/provider/pact_helpers/project/pipeline/show/delete_pipeline_helper.rb
new file mode 100644
index 00000000000..2d29fabfeca
--- /dev/null
+++ b/spec/contracts/provider/pact_helpers/project/pipeline/show/delete_pipeline_helper.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+require_relative '../../../../spec_helper'
+require_relative '../../../../states/project/pipeline/show_state'
+
+module Provider
+ module DeletePipelineHelper
+ Pact.service_provider "DELETE pipeline" do
+ app { Environments::Test.app }
+
+ honours_pact_with 'Pipelines#show' do
+ pact_uri '../contracts/project/pipeline/show/pipelines#show-delete_pipeline.json'
+ end
+ end
+ end
+end
diff --git a/spec/contracts/provider/pact_helpers/project/pipeline/get_pipeline_header_data_helper.rb b/spec/contracts/provider/pact_helpers/project/pipeline/show/get_pipeline_header_data_helper.rb
index abb2781f987..4bc7dff2ef9 100644
--- a/spec/contracts/provider/pact_helpers/project/pipeline/get_pipeline_header_data_helper.rb
+++ b/spec/contracts/provider/pact_helpers/project/pipeline/show/get_pipeline_header_data_helper.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require_relative '../../../spec_helper'
-require_relative '../../../states/project/pipeline/pipeline_state'
+require_relative '../../../../spec_helper'
+require_relative '../../../../states/project/pipeline/pipeline_state'
module Provider
module GetPipelinesHeaderDataHelper
diff --git a/spec/contracts/provider/states/project/pipeline/show_state.rb b/spec/contracts/provider/states/project/pipeline/show_state.rb
new file mode 100644
index 00000000000..3365647cd13
--- /dev/null
+++ b/spec/contracts/provider/states/project/pipeline/show_state.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+Pact.provider_states_for "Pipelines#show" do
+ provider_state "a pipeline for a project exists" do
+ set_up do
+ user = User.find_by(name: Provider::UsersHelper::CONTRACT_USER_NAME)
+ namespace = create(:namespace, name: 'gitlab-org')
+ project = create(:project, :repository, name: 'gitlab-qa', namespace: namespace, creator: user)
+ scheduled_job = create(:ci_build, :scheduled)
+ manual_job = create(:ci_build, :manual)
+
+ project.add_maintainer(user)
+
+ create(
+ :ci_pipeline,
+ :with_job,
+ :success,
+ id: 316112,
+ iid: 1,
+ project: project,
+ user: user,
+ duration: 10,
+ finished_at: '2022-06-01T02:47:31.432Z',
+ builds: [scheduled_job, manual_job]
+ )
+ end
+ end
+end