Commit 2d05521a authored by long nguyen huy's avatar long nguyen huy Committed by Patrick Rice
Browse files

Add `destroy` attribute for pipeline schedule inputs

Changelog: Improvements
parent a505b089
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -407,6 +407,38 @@ func TestPipelineSchedules_EditPipelineSchedule(t *testing.T) {
	assert.Equal(t, want, schedule)
}

func TestPipelineSchedules_EditPipelineScheduleWithDestroyInput(t *testing.T) {
	t.Parallel()
	mux, client := setup(t)

	mux.HandleFunc("/api/v4/projects/1/pipeline_schedules/2", func(w http.ResponseWriter, r *http.Request) {
		testMethod(t, r, http.MethodPut)
		// Validate that destroy: true is sent for the input
		testBodyJSON(t, r, map[string]any{
			"inputs": []any{
				map[string]any{
					"name":    "my_input_name",
					"value":   "my_ci_value",
					"destroy": true,
				},
			},
		})
		fmt.Fprint(w, `{"id": 13}`)
	})

	_, resp, err := client.PipelineSchedules.EditPipelineSchedule(1, 2, &EditPipelineScheduleOptions{
		Inputs: []*PipelineInput{
			{
				Name:    "my_input_name",
				Value:   "my_ci_value",
				Destroy: Ptr(true),
			},
		},
	})
	assert.NoError(t, err)
	assert.NotNil(t, resp)
}

func TestPipelineSchedules_TakeOwnershipOfPipelineSchedule(t *testing.T) {
	t.Parallel()
	mux, client := setup(t)
+3 −2
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ type PipelineVariable struct {
type PipelineInput struct {
	Name    string `json:"name"`
	Value   any    `json:"value"`
	Destroy *bool  `json:"destroy,omitempty"`
}

// Pipeline represents a GitLab pipeline.