Skip to content

Commit 727fba3

Browse files
committed
refactor(test): remove redundant mock resets from test cases and use Run_BeforeEach to set standar mock arange
1 parent 323e027 commit 727fba3

32 files changed

Lines changed: 42 additions & 259 deletions

Test/mockfiles.log

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,5 +202,9 @@
202202
{
203203
"FileName": "invoke-UpdateProjectV2Collaborators-MDQ6VXNlcjY4ODQ0MDg=.json",
204204
"Command": "Invoke-UpdateProjectV2Collaborators -ProjectId PVT_kwDOAlIw4c4BCe3V -collaborators \"\" -Role \"WRITER\""
205+
},
206+
{
207+
"FileName": "invoke-GitHubOrgProjectWithFields-octodemo-700-query-field-text.json",
208+
"Command": "Invoke-GitHubOrgProjectWithFields -Owner octodemo -ProjectNumber 700 -afterFields \"\" -afterItems \"\" -query \"updated:<2025-03-15\""
205209
}
206210
]
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
function Test_GetUser_SUCCESS{
2-
Reset-InvokeCommandMock
3-
Mock_DatabaseRoot
42

53
Assert-NotImplemented
64
}

Test/public/edit-sync-projectitem-comments.test.ps1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
function Test_Edit_Sync_ProjectItem_AddComments_Issue {
2-
3-
Reset-InvokeCommandMock
4-
Mock_DatabaseRoot
52

63
$p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number
74
$i = $p.issue

Test/public/environmentCache.test.ps1

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
function Test_EnvironmentCache{
66

7-
Reset-InvokeCommandMock
8-
Mock_DatabaseRoot
9-
107
$p = Get-Mock_Project_700 ; $Owner = $p.owner ; $projectNumber = $p.number
118
$i = $p.issue
129
$f = $p.fieldtext
@@ -18,8 +15,7 @@ function Test_EnvironmentCache{
1815
MockCall_GetProject_700 -Cache
1916

2017
# Reset mock calls
21-
Reset-invokeCommandMock
22-
Mock_DatabaseRoot -NotReset
18+
Reset_Test_Mock -NoResetDatabase
2319

2420
$itemId = $i.Id
2521
$fieldTitleValue = $i.title

Test/public/getPrompt.test.ps1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
function Test_GetProjecthelperPrompt {
22

3-
Reset-InvokeCommandMock
4-
Mock_DatabaseRoot
5-
63
$owner = "octodemo"
74
$projectNumber = "625"
85
$s = $ProjecthelperPromoptSettings

Test/public/integrations/Edit-ProjectItemWithValues.test.ps1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
function Test_EditProjectItemWithValues_Integration {
22

33
# Assert-SkipTest
4-
Reset-InvokeCommandMock
5-
Mock_DatabaseRoot
64

75
$owner = "octodemo"
86
$projectNumber = "625"

Test/public/integrations/sync-ProjectItemsBetweenProjects.test.ps1

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
function Test_UpdateProjectItemsBetweenProjects{
2-
Reset-InvokeCommandMock
3-
Mock_DatabaseRoot
42

53
$p625 = Get-Mock_Project_625 ; $owner0 = $p625.owner ; $projectNumber0 = $p625.number
64
$p626 = Get-Mock_Project_626 ; $owner1 = $p626.owner ; $projectNumber1 = $p626.number
@@ -38,8 +36,6 @@ function Test_UpdateProjectItemsBetweenProjects{
3836
}
3937

4038
function Test_UpdateProjectItemsBetweenProjects_NoRefresh_NoRefresh{
41-
Reset-InvokeCommandMock
42-
Mock_DatabaseRoot
4339

4440
$p625 = Get-Mock_Project_625 ; $owner0 = $p625.owner ; $projectNumber0 = $p625.number
4541
$p626 = Get-Mock_Project_626 ; $owner1 = $p626.owner ; $projectNumber1 = $p626.number
@@ -51,8 +47,7 @@ function Test_UpdateProjectItemsBetweenProjects_NoRefresh_NoRefresh{
5147
MockCall_GetProject -MockProject $p626 -Cache
5248

5349
# Reset mocks to fail if mocks are called again
54-
Reset-InvokeCommandMock
55-
Mock_DatabaseRoot -NotReset
50+
Reset_Test_Mock -NoResetDatabase
5651

5752
# Act
5853

@@ -75,8 +70,6 @@ function Test_UpdateProjectItemsBetweenProjects_NoRefresh_NoRefresh{
7570
}
7671

7772
function Test_SyncProjectItemsBetweenProjects_SameValues{
78-
Reset-InvokeCommandMock
79-
Mock_DatabaseRoot
8073

8174
MockCall_GetProject_700
8275
$p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number

Test/public/integrations/update-ProjectImtesWithInjection.test.ps1

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
function Test_UpdateProjectWithInjection{
44

5-
Reset-InvokeCommandMock
6-
Mock_DatabaseRoot
7-
85
# https://github.com/orgs/octodemo/projects/625/views/1
96

107
$mp = Get-Mock_Project_625 ; $owner = $mp.owner ; $projectNumber = $mp.number
@@ -87,9 +84,6 @@ function Test_UpdateProjectWithInjection{
8784

8885
function Test_UpdateProjectWithInjection_Failed_1{
8986

90-
Reset-InvokeCommandMock
91-
Mock_DatabaseRoot
92-
9387
# https://github.com/orgs/octodemo/projects/625/views/1
9488

9589
$mp = Get-Mock_Project_625 ; $owner = $mp.owner ; $projectNumber = $mp.number
@@ -165,9 +159,6 @@ function Test_UpdateProjectWithInjection_Failed_1{
165159

166160
function Test_InvokeProjectInjection{
167161

168-
Reset-InvokeCommandMock
169-
Mock_DatabaseRoot
170-
171162
$owner = "octodemo"
172163
$projectNumber = "625"
173164

@@ -210,10 +201,7 @@ function Test_InvokeProjectInjection{
210201

211202
function Test_InvokeProjectInjection_Fail{
212203

213-
Reset-InvokeCommandMock
214-
Mock_DatabaseRoot
215-
216-
$owner = "octodemo"
204+
$owner = "octodemo"
217205
$projectNumber = "625"
218206

219207
MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName "invoke-GitHubOrgProjectWithFields-$owner-$projectNumber-skipitems.json" -SkipItems

Test/public/integrations/update-ProjectItemsStatusOnDueDate.test.ps1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
function Test_UpdateProjectItemStatusOnDueDate {
22

3-
Reset-InvokeCommandMock
4-
Mock_DatabaseRoot
5-
63
# Mock calling Toda
74
MockCallToString -Command "Get-Date -Format yyyy-MM-dd" -OutString "2025-03-15"
85

Test/public/integrations/update-ProjectItemsWithIntegration.test.ps1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
function Test_UpdateProjectWithIntegration{
22

3-
Reset-InvokeCommandMock
4-
Mock_DatabaseRoot
5-
63
$mp = Get-Mock_Project_625 ; $owner = $mp.owner ; $projectNumber = $mp.number
74
Mockcall_GetProject -MockProject $mp
85
$p = $mp.updateWithIntegration

0 commit comments

Comments
 (0)