Verified Commit 49dea058 authored by Florian Forster's avatar Florian Forster
Browse files

fix(test): Use epic IID instead of ID in `DeleteEpic` cleanup.

The `DeleteEpic` function requires the epic's internal ID (IID), scoped per
group, not the global ID.

This bug went undetected because only a single epic was ever created across all
integration tests. With exactly one epic in the system, its global ID and its
group-scoped IID are both 1 — so passing the wrong field had no observable
effect.

Adding `TestCreateWorkItem` in !2751, which creates a
work item of type Epic, incremented the global epic ID counter to 2
independently of the IID sequence. The epic created by
`TestEpicTimeFieldParsing` then received IID 1 within its group but global ID
2. The cleanup function passed global ID 2 to `DeleteEpic`, which the API
rejected with 403 Forbidden since no epic with IID 2 existed in that group.
parent 1e294d44
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -269,7 +269,7 @@ func CreateTestEpicWithOptions(t *testing.T, client *gitlab.Client, gid any, opt

	// Add a cleanup function
	t.Cleanup(func() {
		_, err := client.Epics.DeleteEpic(gid, epic.ID, gitlab.WithContext(context.Background()))
		_, err := client.Epics.DeleteEpic(gid, epic.IID, gitlab.WithContext(context.Background()))
		require.NoError(t, err, "Failed to delete test epic")
	})