test(workitems): split t.Run() sub-tests into individual parent test functions
Summary
Refactors workitems_test.go to replace large table-driven t.Run() blocks with individual top-level TestXxx functions per scenario, as requested in #2273 (closed).
What changed
-
Split
TestGetWorkItem(3 sub-tests) → 3 top-level functions:TestGetWorkItem_SuccessfulResponseTestGetWorkItem_EmptyNodesReturnsNotFoundTestGetWorkItem_NullProjectReturnsNotFound
-
Split
TestListWorkItems(4 sub-tests) → 4 top-level functions:TestListWorkItems_SuccessfulQueryWithAuthorUsernameTestListWorkItems_SuccessfulResponseWithSingleWorkItemTestListWorkItems_EmptyResponseIsNotAnErrorTestListWorkItems_AllOptionsFieldsIncludedInQuery
-
Split
TestCreateWorkItem(6 sub-tests, 2 were duplicates) → 5 top-level functions:TestCreateWorkItem_SuccessfulCreationWithTitleOnlyTestCreateWorkItem_SuccessfulCreationWithAllOptionsTestCreateWorkItem_MutationErrorReturnsErrorTestCreateWorkItem_GraphQLErrorReturnsErrorTestCreateWorkItem_NullWorkItemReturnsEmptyResponseError
-
Split
TestUpdateWorkItem(5 sub-tests) → 5 top-level functions:TestUpdateWorkItem_SuccessfulUpdateWithTitleOnlyTestUpdateWorkItem_SuccessfulUpdateWithAllOptionsTestUpdateWorkItem_WorkItemNotFoundDuringIDLookupTestUpdateWorkItem_MutationReturnsNullWorkItemTestUpdateWorkItem_MutationReturnsError
-
Split
TestDeleteWorkItem(4 sub-tests) → 4 top-level functions:TestDeleteWorkItem_SuccessfullyDeletesWorkItemTestDeleteWorkItem_WorkItemNotFoundReturnsErrorTestDeleteWorkItem_NamespaceNotFoundReturnsErrorTestDeleteWorkItem_MutationReturnsErrors
-
Extracted shared helpers:
setupGraphQLHandler(new) andwriteResponse(new) reduce boilerplate in each test function while keepingsetupWorkItemTypesHandlerandassertQueryMatchesas-is. -
Added Gherkin-style comments: Every test function has
// GIVEN,// WHEN, and// THENinline comments per the project's test conventions. -
All 29 test functions call
t.Parallel().
Why
Individual top-level test functions are significantly easier to debug — failures point directly to the failing function. VSCode (and other editors) can discover and run individual tests without needing a prior test run to populate sub-test names.
Related
Closes #2273 (closed)