From 666f8f0a01ef8ba8510ccbff40c3a271db99d91e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 18 Jan 2026 21:27:11 +0100 Subject: [PATCH 01/13] feat(project): add Update-ProjectRecent function to manage recent project updates --- public/project/getproject.ps1 | 6 ++++ public/project/updateprojectrecent.ps1 | 49 ++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 public/project/updateprojectrecent.ps1 diff --git a/public/project/getproject.ps1 b/public/project/getproject.ps1 index 11cb9ce..0628e0a 100644 --- a/public/project/getproject.ps1 +++ b/public/project/getproject.ps1 @@ -42,6 +42,12 @@ function Update-Project{ $ret = Update-ProjectDatabase -Owner $Owner -ProjectNumber $ProjectNumber -SkipItems:$SkipItems -Query $Query + # Check if we did a full projectupdate + if([string]::IsNullOrEmpty($Query)){ + # Reset recent to today + Set-EnvItem_Last_RecentUpdate_Today -Owner $Owner -ProjectNumber $ProjectNumber + } + return $ret } Export-ModuleMember -Function Update-Project diff --git a/public/project/updateprojectrecent.ps1 b/public/project/updateprojectrecent.ps1 new file mode 100644 index 0000000..77c61bd --- /dev/null +++ b/public/project/updateprojectrecent.ps1 @@ -0,0 +1,49 @@ +function Update-ProjectRecent{ + [CmdletBinding()] + param( + [Parameter()][string]$Owner, + [Parameter()][int]$ProjectNumber + ) + + ($Owner, $ProjectNumber) = Get-OwnerAndProjectNumber -Owner $Owner -ProjectNumber $ProjectNumber + if ([string]::IsNullOrWhiteSpace($owner) -or [string]::IsNullOrWhiteSpace($ProjectNumber)) { + throw "Owner and ProjectNumber are required on Update-Project" + } + + # Get Last update date + $last = Get-EnvItem_Last_RecentUpdate -Owner $Owner -ProjectNumber $ProjectNumber + + $Query = "updated:<$last" + + $ret = Update-ProjectDatabase -Owner $Owner -ProjectNumber $ProjectNumber -SkipItems:$SkipItems -Query $Query + + if($result){ + Set-EnvItem_Last_RecentUpdate_Today -Owner $Owner -ProjectNumber $ProjectNumber + } + + return $ret +} Export-ModuleMember -Function Update-ProjectRecent + +function Set-EnvItem_Last_RecentUpdate_Today{ + [CmdletBinding()] + param( + [Parameter(Mandatory)][string]$Owner, + [Parameter(Mandatory)][int]$ProjectNumber + ) + + $now = Get-DateToday + Set-EnvItem -Name "EnvironmentCache_Last_RecentUpdate_$($Owner)_$($ProjectNumber)" -Value $now + +} + +function Get-EnvItem_Last_RecentUpdate{ + [CmdletBinding()] + param( + [Parameter(Mandatory)][string]$Owner, + [Parameter(Mandatory)][int]$ProjectNumber + ) + + $last = Get-EnvItem -Name "EnvironmentCache_Last_RecentUpdate_$($Owner)_$($ProjectNumber)" + + return $last +} \ No newline at end of file From 6532dd2b5d63bb3d32dc8916544e072d4d9f8d6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 18 Jan 2026 21:27:25 +0100 Subject: [PATCH 02/13] refactor(test): update global variable handling for TestName --- test.ps1 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/test.ps1 b/test.ps1 index b477ff6..f52014c 100644 --- a/test.ps1 +++ b/test.ps1 @@ -14,7 +14,8 @@ [CmdletBinding()] param ( - [Parameter()][switch]$ShowTestErrors + [Parameter()][switch]$ShowTestErrors, + [Parameter()][string]$TestName ) function Set-TestName{ @@ -28,7 +29,7 @@ function Set-TestName{ ) process{ - $global:TestName = $TestName + $global:TestNameVar = $TestName } } @@ -40,7 +41,7 @@ function Get-TestName{ ) process{ - $global:TestName + $global:TestNameVar } } @@ -52,7 +53,7 @@ function Clear-TestName{ param ( ) - $global:TestName = $null + $global:TestNameVar = $null } function Import-RequiredModule{ @@ -137,8 +138,9 @@ Import-RequiredModule "TestingHelper" -AllowPrerelease # Install and Load Module dependencies Get-RequiredModule | Import-RequiredModule -AllowPrerelease -if($TestName){ - Invoke-TestingHelper -TestName $TestName -ShowTestErrors:$ShowTestErrors -} else { - Invoke-TestingHelper -ShowTestErrors:$ShowTestErrors -} +# Resolve scoped tests +$TestName = [string]::IsNullOrWhiteSpace($TestName) ? $global:TestNameVar : $TestName + +# Call TestingHelper to run the tests +Invoke-TestingHelper -TestName $TestName -ShowTestErrors:$ShowTestErrors + From 77840b7e5850cac09530a39169f5eed2de4fc9f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 18 Jan 2026 22:41:44 +0100 Subject: [PATCH 03/13] feat(mock): add Mock_Today function to retrieve today's date --- Test/private/MockCall_Project.ps1 | 2 ++ Test/private/MockCall_Project700.ps1 | 2 ++ Test/private/Mock_Today.ps1 | 14 ++++++++++++++ 3 files changed, 18 insertions(+) create mode 100644 Test/private/Mock_Today.ps1 diff --git a/Test/private/MockCall_Project.ps1 b/Test/private/MockCall_Project.ps1 index 9ce4b6c..b106e4b 100644 --- a/Test/private/MockCall_Project.ps1 +++ b/Test/private/MockCall_Project.ps1 @@ -214,6 +214,8 @@ function MockCall_GetProject { } MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName $filename -SkipItems:$SkipItems + Mock_Today + if ($Cache) { $null = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -SkipItems:$SkipItems diff --git a/Test/private/MockCall_Project700.ps1 b/Test/private/MockCall_Project700.ps1 index 044019b..2c9b4ea 100644 --- a/Test/private/MockCall_Project700.ps1 +++ b/Test/private/MockCall_Project700.ps1 @@ -241,6 +241,7 @@ function MockCall_GetProject_700 { } MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName $filename -SkipItems:$SkipItems + Mock_Today if ($Cache) { $null = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -SkipItems:$SkipItems @@ -260,6 +261,7 @@ function MockCall_GetProject_700_CaseSensitive { $filename = $p.projectFile_caseSensitive MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName $filename -SkipItems:$SkipItems + Mock_Today if ($Cache) { $null = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -SkipItems:$SkipItems diff --git a/Test/private/Mock_Today.ps1 b/Test/private/Mock_Today.ps1 new file mode 100644 index 0000000..38aea7b --- /dev/null +++ b/Test/private/Mock_Today.ps1 @@ -0,0 +1,14 @@ +function Get-Mock_Today{ + $ret = @{ + today = "2024-06-30" + # today = "2025-03-15" + } + + return $ret +} + +function Mock_Today{ + + $today = (Get-Mock_Today).today + MockCallToString -Command "Get-Date -Format yyyy-MM-dd" -OutString $today +} \ No newline at end of file From 462f2c348d6d4d4e0f6aa541268d63acff94a8a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 18 Jan 2026 22:44:38 +0100 Subject: [PATCH 04/13] fix(test): comment out Enable-InvokeCommandAliasModule in Test_FindProject_SUCCESS --- Test/public/project/findproject.test.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Test/public/project/findproject.test.ps1 b/Test/public/project/findproject.test.ps1 index 80085bb..7e8820f 100644 --- a/Test/public/project/findproject.test.ps1 +++ b/Test/public/project/findproject.test.ps1 @@ -1,7 +1,7 @@ function Test_FindProject_SUCCESS { Reset-InvokeCommandMock - Enable-InvokeCommandAliasModule + # Enable-InvokeCommandAliasModule $owner = "github" From 30b48fee86087445a3d21b53a5dcb107564aedd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 18 Jan 2026 22:45:04 +0100 Subject: [PATCH 05/13] feat(includeFiles): add functions to run before and after tests --- Test/include/run_BeforeAfter.ps1 | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Test/include/run_BeforeAfter.ps1 diff --git a/Test/include/run_BeforeAfter.ps1 b/Test/include/run_BeforeAfter.ps1 new file mode 100644 index 0000000..48d34ff --- /dev/null +++ b/Test/include/run_BeforeAfter.ps1 @@ -0,0 +1,26 @@ +# Run Before and After any test +# +# Supported by TestingHelper 4.1.0 we can specify code that will run : +# - Before each test +# - After each test +# - Before all tests +# - After all tests + +function Run_BeforeAll{ + Write-Verbose "Run_BeforeAll" +} + +function Run_AfterAll{ + Write-Verbose "Run_AfterAll" +} + +function Run_BeforeEach{ + Write-Verbose "Run_BeforeEach" +} + +function Run_AfterEach{ + Write-Verbose "Run_AfterEach" +} + +Export-ModuleMember -Function Run_* + From 459b689cf08f368db88a61af6120d32ffc751ee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 18 Jan 2026 22:49:07 +0100 Subject: [PATCH 06/13] fix(project): correct query assignment in Update-ProjectRecent function --- public/project/updateprojectrecent.ps1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/public/project/updateprojectrecent.ps1 b/public/project/updateprojectrecent.ps1 index 77c61bd..1f1f294 100644 --- a/public/project/updateprojectrecent.ps1 +++ b/public/project/updateprojectrecent.ps1 @@ -12,10 +12,9 @@ function Update-ProjectRecent{ # Get Last update date $last = Get-EnvItem_Last_RecentUpdate -Owner $Owner -ProjectNumber $ProjectNumber + $query = ($null -eq $last) ? $null : "updated:<$last" - $Query = "updated:<$last" - - $ret = Update-ProjectDatabase -Owner $Owner -ProjectNumber $ProjectNumber -SkipItems:$SkipItems -Query $Query + $ret = Update-Project -Owner $Owner -ProjectNumber $ProjectNumber -SkipItems:$SkipItems -Query $Query if($result){ Set-EnvItem_Last_RecentUpdate_Today -Owner $Owner -ProjectNumber $ProjectNumber From 8c2fcdd0477c7766a470f74a8f1f37c0908c40cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 18 Jan 2026 22:49:57 +0100 Subject: [PATCH 07/13] fix(test): remove commented Enable-InvokeCommandAliasModule commented code in Test_FindProject_SUCCESS function --- Test/public/project/findproject.test.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/Test/public/project/findproject.test.ps1 b/Test/public/project/findproject.test.ps1 index 7e8820f..811c93c 100644 --- a/Test/public/project/findproject.test.ps1 +++ b/Test/public/project/findproject.test.ps1 @@ -1,7 +1,6 @@ function Test_FindProject_SUCCESS { Reset-InvokeCommandMock - # Enable-InvokeCommandAliasModule $owner = "github" From 05666e454eb654529d176119b05aa9dd6f60f6dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 18 Jan 2026 22:51:56 +0100 Subject: [PATCH 08/13] fix(mock): update date values in Get-Mock_Today function --- Test/private/Mock_Today.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Test/private/Mock_Today.ps1 b/Test/private/Mock_Today.ps1 index 38aea7b..e903445 100644 --- a/Test/private/Mock_Today.ps1 +++ b/Test/private/Mock_Today.ps1 @@ -1,7 +1,7 @@ function Get-Mock_Today{ $ret = @{ - today = "2024-06-30" - # today = "2025-03-15" + # today = "2024-06-30" + today = "2025-03-15" } return $ret From 28437a67036b5eb3013429be696dbe08eecf87ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 18 Jan 2026 22:52:26 +0100 Subject: [PATCH 09/13] test(project): add unit tests for Update-ProjectRecent functionality --- .../project/updateprojectrecent.test.ps1 | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Test/public/project/updateprojectrecent.test.ps1 diff --git a/Test/public/project/updateprojectrecent.test.ps1 b/Test/public/project/updateprojectrecent.test.ps1 new file mode 100644 index 0000000..86db10a --- /dev/null +++ b/Test/public/project/updateprojectrecent.test.ps1 @@ -0,0 +1,74 @@ +function Test_UpdateProject_SetsRecentUpdateToday_WhenQueryIsNull{ + # Arrange + Reset-InvokeCommandMock + Mock_DatabaseRoot + + $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number + $today = (Get-Mock_Today).today + + MockCall_GetProject $p + + # Act + $result = Update-Project -Owner $owner -ProjectNumber $projectNumber + + # Assert + Assert-IsTrue $result + + # Verify Set-EnvItem_Last_RecentUpdate_Today was called - check the env item is set to today + $envValue = Invoke-PrivateContext { Get-EnvItem_Last_RecentUpdate -Owner "octodemo" -ProjectNumber 700 } + + Assert-AreEqual -Expected $today -Presented $envValue -Comment "Set-EnvItem_Last_RecentUpdate_Today should set env item to today when Query is null" +} + +function Test_UpdateProjectRecent_FirstCAll_SetRecentUpdate_toToday{ + # Arrange + Reset-InvokeCommandMock + Mock_DatabaseRoot + Mock_Today + + $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number + $today = (Get-Mock_Today).today + + # Mock full sync to be called by Update-ProjectRecent first time + MockCall_GetProject_700 + + # Act first call will sync full with query to null + $result = Update-ProjectRecent -Owner $owner -ProjectNumber $projectNumber + + # Assert + Assert-IsTrue $result + + # Verify Set-EnvItem_Last_RecentUpdate_Today was NOT called - env item should be null/empty + $envValue = Invoke-PrivateContext { Get-EnvItem_Last_RecentUpdate -Owner "octodemo" -ProjectNumber 700 } + Assert-IsNotNull -Object $envValue + Assert-AreEqual -Expected $today -Presented $envValue + +} + +function Test_UpdateProjectRecent_UpdateBasedOn_SetRecentUpdate{ + # Arrange + + Reset-InvokeCommandMock + $today = (Get-Mock_Today).today + MockCallToString -Command "Get-Date -Format yyyy-MM-dd" -OutString $today + + # Cache project + Mock_DatabaseRoot + MockCall_GetProject_700 -Cache + + Reset-InvokeCommandMock + Mock_DatabaseRoot -NotReset + MockCallToString -Command "Get-Date -Format yyyy-MM-dd" -OutString $today + + $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number + $query = "updated:<$today" + # not real query just a mock file with some items reply + $fileName = $p.getProjectWithQuery.getProjectWithQueryMockFile + + # Set te only sync allowed on Update-ProjectRecent + MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -Query $query -FileName $fileName + + # Act second time - call Update-ProjectRecent again to ensure it uses the last recent update date + $result = Update-ProjectRecent -Owner $owner -ProjectNumber $projectNumber + Assert-IsTrue $result +} From cc0a4cf18b53e8e81a076bda681eb5e7f3d4f4bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 18 Jan 2026 23:05:33 +0100 Subject: [PATCH 10/13] refactor(test): replace MockCall_GitHubOrgProjectWithFields with MockCall_GetProject_700 in test files --- Test/public/project_fields_list.test.ps1 | 2 +- Test/public/project_item.test.ps1 | 4 ++-- Test/public/project_items_staged.test.ps1 | 24 +++++++++---------- .../project_items_staged_Async.test.ps1 | 18 +++++++------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Test/public/project_fields_list.test.ps1 b/Test/public/project_fields_list.test.ps1 index a38c0c5..bfe35cd 100644 --- a/Test/public/project_fields_list.test.ps1 +++ b/Test/public/project_fields_list.test.ps1 @@ -63,7 +63,7 @@ function Test_GetProjectFields_SUCCESS_FilterByName{ # title refrence with differnt case and spaces $filter = "Title" - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'projectV2-skipitems.json' -SkipItems + MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'projectV2-skipitems.json' -SkipItems $result = Get-ProjectFields -Owner $owner -ProjectNumber $projectNumber -Name $filter diff --git a/Test/public/project_item.test.ps1 b/Test/public/project_item.test.ps1 index 2dcf364..425b917 100644 --- a/Test/public/project_item.test.ps1 +++ b/Test/public/project_item.test.ps1 @@ -162,7 +162,7 @@ function Test_EditProjectItems_SameValue{ Mock_DatabaseRoot $Owner = "octodemo" ; $ProjectNumber = 700 - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700.json' + MockCall_GetProject_700 $prj = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber #$actualtitle = $prj.items.$itemId."Title" @@ -271,7 +271,7 @@ function Test_EditProjectItems_Direct{ $Owner = "octodemo" ; $ProjectNumber = 700 # No sync of project with items allowed just with skipitems - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700-skipitems.json' -skipitems + MockCall_GetProject_700 -skipItems $itemId = "PVTI_lADOAlIw4c4BCe3Vzgeio4o" $fieldComment = "field-text" ; $fieldCommentValue = "new value of the comment 10.1" diff --git a/Test/public/project_items_staged.test.ps1 b/Test/public/project_items_staged.test.ps1 index 5ffc7a1..4d79332 100644 --- a/Test/public/project_items_staged.test.ps1 +++ b/Test/public/project_items_staged.test.ps1 @@ -55,8 +55,8 @@ function Test_SyncProjectItemsStaged_SUCCESS_Number{ } # Mock get-project - # MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700-skipitems.json' -skipItems - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700.json' + # MockCall_GetProject_700 -skipItems + MockCall_GetProject_700 $null = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -Force Edit-ProjectItem -Owner $owner -ProjectNumber $projectNumber $itemId1 $fieldName $fieldValue @@ -123,7 +123,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_Date{ } # Mock get-project - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700.json' + MockCall_GetProject_700 $null = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber Edit-ProjectItem -Owner $owner -ProjectNumber $projectNumber $itemId1 $fieldName $fieldValue @@ -300,7 +300,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_Issue_NotCached { Set-InvokeCommandMock -Command "Get-MockFileContentJson -filename invoke-getitem-$itemId1.json" -Alias "Invoke-GetItem -ItemId $itemId1" # Mock get-project - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700-skipitems.json' -skipItems + MockCall_GetProject_700 -skipItems # Edit fields Edit-ProjectItem -Owner $owner -ProjectNumber $projectNumber $itemId1 $fieldComment1 $fieldCommentValue1 @@ -393,7 +393,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_PullRequest_NotCached { Set-InvokeCommandMock -Command "Get-MockFileContentJson -filename invoke-getitem-$itemId1.json" -Alias "Invoke-GetItem -ItemId $itemId1" # Mock get-project - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700-skipitems.json' -skipItems + MockCall_GetProject_700 -skipItems # Edit fields Edit-ProjectItem -Owner $owner -ProjectNumber $projectNumber $itemId1 $fieldComment1 $fieldCommentValue1 @@ -485,7 +485,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_DraftIssue_NotCached { Set-InvokeCommandMock -Command "Get-MockFileContentJson -filename invoke-getitem-$itemId1.json" -Alias "Invoke-GetItem -ItemId $itemId1" # Mock get-project - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700-skipitems.json' -skipItems + MockCall_GetProject_700 -skipItems # Edit fields Edit-ProjectItem -Owner $owner -ProjectNumber $projectNumber $itemId1 $fieldComment1 $fieldCommentValue1 @@ -515,7 +515,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_Issue { $Owner = "octodemo" ; $ProjectNumber = 700 # Mock this call to cache the project in the test - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700.json' + MockCall_GetProject_700 $project = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -Force $projectId = $project.ProjectId @@ -579,7 +579,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_Issue { } # Mock get-project - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700-skipitems.json' -skipItems + MockCall_GetProject_700 -skipItems # Edit fields Edit-ProjectItem -Owner $owner -ProjectNumber $projectNumber $itemId1 $fieldTitle1 $fieldTitleValue1 @@ -609,7 +609,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_PullRequest { $Owner = "octodemo" ; $ProjectNumber = 700 # Mock this call to cache the project in the test - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700.json' + MockCall_GetProject_700 $project = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -Force $projectId = $project.ProjectId @@ -671,7 +671,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_PullRequest { } # Mock get-project (skip items) - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700-skipitems.json' -skipItems + MockCall_GetProject_700 -skipItems # Edit fields (keep same order pattern as Issue test) Edit-ProjectItem -Owner $owner -ProjectNumber $projectNumber $itemId1 $fieldTitle1 $fieldTitleValue1 @@ -700,7 +700,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_DraftIssue { $Owner = "octodemo" ; $ProjectNumber = 700 # Cache project first - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700.json' + MockCall_GetProject_700 $project = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -Force $projectId = $project.ProjectId @@ -765,7 +765,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_DraftIssue { } # Mock get-project (skip items) - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700-skipitems.json' -skipItems + MockCall_GetProject_700 -skipItems # Edit fields (match order used in Issue / PullRequest tests) Edit-ProjectItem -Owner $owner -ProjectNumber $projectNumber $itemId1 $fieldTitle1 $fieldTitleValue1 diff --git a/Test/public/project_items_staged_Async.test.ps1 b/Test/public/project_items_staged_Async.test.ps1 index 4e32552..e6d2ff5 100644 --- a/Test/public/project_items_staged_Async.test.ps1 +++ b/Test/public/project_items_staged_Async.test.ps1 @@ -91,7 +91,7 @@ function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_Issue_NotCached { Set-InvokeCommandMock -Command "Get-MockFileContentJson -filename invoke-getitem-$itemId1.json" -Alias "Invoke-GetItem -ItemId $itemId1" # Mock get-project - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700-skipitems.json' -skipItems + MockCall_GetProject_700 -skipItems # Edit fields Edit-ProjectItem -Owner $owner -ProjectNumber $projectNumber $itemId1 $fieldComment1 $fieldCommentValue1 @@ -191,7 +191,7 @@ function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_PullRequest_NotCached Set-InvokeCommandMock -Command "Import-Module $moduleTestPath ; Get-MockFileContentJson -filename invoke-getitem-$itemId1.json" -Alias "Invoke-GetItem -ItemId $itemId1" # Mock get-project - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700-skipitems.json' -skipItems + MockCall_GetProject_700 -skipItems # Edit fields Edit-ProjectItem -Owner $owner -ProjectNumber $projectNumber $itemId1 $fieldComment1 $fieldCommentValue1 @@ -290,7 +290,7 @@ function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_DraftIssue_NotCached Set-InvokeCommandMock -Command "Import-Module $moduleTestPath ; Get-MockFileContentJson -filename invoke-getitem-$itemId1.json" -Alias "Invoke-GetItem -ItemId $itemId1" # Mock get-project - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700-skipitems.json' -skipItems + MockCall_GetProject_700 -skipItems # Edit fields Edit-ProjectItem -Owner $owner -ProjectNumber $projectNumber $itemId1 $fieldComment1 $fieldCommentValue1 @@ -324,7 +324,7 @@ function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_Issue { $Owner = "octodemo" ; $ProjectNumber = 700 # Mock this call to cache the project in the test - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700.json' + MockCall_GetProject_700 $project = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -Force $projectId = $project.ProjectId @@ -394,7 +394,7 @@ function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_Issue { } # Mock get-project - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700-skipitems.json' -skipItems + MockCall_GetProject_700 -skipItems # Edit fields Edit-ProjectItem -Owner $owner -ProjectNumber $projectNumber $itemId1 $fieldTitle1 $fieldTitleValue1 @@ -428,7 +428,7 @@ function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_PullRequest { $Owner = "octodemo" ; $ProjectNumber = 700 # Cache project (with items) so it is stored locally - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700.json' + MockCall_GetProject_700 $project = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -Force $projectId = $project.ProjectId @@ -494,7 +494,7 @@ function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_PullRequest { } # Mock project (skip items) - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700-skipitems.json' -skipItems + MockCall_GetProject_700 -skipItems # Stage edits (order similar to Issue/DraftIssue tests) Edit-ProjectItem -Owner $owner -ProjectNumber $projectNumber $itemId1 $fieldTitle1 $fieldTitleValue1 @@ -527,7 +527,7 @@ function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_DraftIssue { $Owner = "octodemo" ; $ProjectNumber = 700 # Cache project (with items) so it is stored locally - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700.json' + MockCall_GetProject_700 $project = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -Force $projectId = $project.ProjectId @@ -593,7 +593,7 @@ function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_DraftIssue { } # Mock project (skip items) - MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'invoke-GitHubOrgProjectWithFields-octodemo-700-skipitems.json' -skipItems + MockCall_GetProject_700 -skipItems # Stage edits (order similar to Issue test) Edit-ProjectItem -Owner $owner -ProjectNumber $projectNumber $itemId1 $fieldTitle1 $fieldTitleValue1 From 49bad9185eef4c363aadcd051d86c54fb975e61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 18 Jan 2026 23:34:05 +0100 Subject: [PATCH 11/13] feat(test): add Reset_Test_Mock function and integrate it in Run_BeforeEach --- Test/include/run_BeforeAfter.ps1 | 2 ++ Test/private/Reset_TestMock.ps1 | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 Test/private/Reset_TestMock.ps1 diff --git a/Test/include/run_BeforeAfter.ps1 b/Test/include/run_BeforeAfter.ps1 index 48d34ff..80273af 100644 --- a/Test/include/run_BeforeAfter.ps1 +++ b/Test/include/run_BeforeAfter.ps1 @@ -16,6 +16,8 @@ function Run_AfterAll{ function Run_BeforeEach{ Write-Verbose "Run_BeforeEach" + + Reset_Test_Mock } function Run_AfterEach{ diff --git a/Test/private/Reset_TestMock.ps1 b/Test/private/Reset_TestMock.ps1 new file mode 100644 index 0000000..9f9f477 --- /dev/null +++ b/Test/private/Reset_TestMock.ps1 @@ -0,0 +1,10 @@ +function Reset_Test_Mock{ + [cmdletbinding()] + param( + [switch]$NoResetDatabase + ) + + Reset-InvokeCommandMock + Mock_DatabaseRoot -NotReset:$NoResetDatabase + Mock_Today +} \ No newline at end of file From 323e027f60876f3407019abb7ec107ca7772661b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 18 Jan 2026 23:36:30 +0100 Subject: [PATCH 12/13] refactor(copilot): streamline Arrange phase in Test_AddProjectUser functions --- .github/instructions/test.instructions.md | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/instructions/test.instructions.md b/.github/instructions/test.instructions.md index d3ca8aa..f77fed2 100644 --- a/.github/instructions/test.instructions.md +++ b/.github/instructions/test.instructions.md @@ -130,6 +130,7 @@ This allows the test infrastructure to recognize the test while explicitly marki ### Example 1: Simple Success Case ```powershell function Test_FindProject_SUCCESS { + # Arrange Reset-InvokeCommandMock Enable-InvokeCommandAliasModule @@ -153,10 +154,8 @@ function Test_FindProject_SUCCESS { ### Example 2: Single vs Multiple User Variants ```powershell function Test_AddProjectUser_SUCCESS_SingleUser { - # Arrange - Reset-InvokeCommandMock - Mock_DatabaseRoot + # Arrange $p = Get-Mock_Project_700 $owner = $p.Owner $projectNumber = $p.Number @@ -179,14 +178,9 @@ function Test_AddProjectUser_SUCCESS_SingleUser { } function Test_AddProjectUser_SUCCESS_MultipleUser { - # Arrange - Reset-InvokeCommandMock - Mock_DatabaseRoot - $p = Get-Mock_Project_700 - $owner = $p.Owner - $projectNumber = $p.Number - $projectId = $p.id + # Arrange + $p = Get-Mock_Project_700 ; $owner = $p.Owner ; $projectNumber = $p.Number ; $projectId = $p.id MockCall_GetProject $p -SkipItems $u = Get-Mock_Users From 727fba34e0498bb3d25cf0446dc9a804a47a8908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 18 Jan 2026 23:41:54 +0100 Subject: [PATCH 13/13] refactor(test): remove redundant mock resets from test cases and use Run_BeforeEach to set standar mock arange --- Test/mockfiles.log | 4 ++ Test/public/driver/user/user.test.ps1 | 2 - .../edit-sync-projectitem-comments.test.ps1 | 3 -- Test/public/environmentCache.test.ps1 | 6 +-- Test/public/getPrompt.test.ps1 | 3 -- .../Edit-ProjectItemWithValues.test.ps1 | 2 - .../sync-ProjectItemsBetweenProjects.test.ps1 | 9 +--- .../update-ProjectImtesWithInjection.test.ps1 | 14 +------ ...pdate-ProjectItemsStatusOnDueDate.test.ps1 | 3 -- ...pdate-ProjectItemsWithIntegration.test.ps1 | 3 -- .../interactive_test/getproject.test.ps1 | 2 - .../Add-IssuePullRequestComment.test.ps1 | 6 --- .../issues/Add-ProjectSubIssue.test.ps1 | 6 --- Test/public/issues/Get-ProjectIssue.test.ps1 | 3 -- Test/public/issues/New-ProjectIssue.test.ps1 | 5 --- .../issues/Remove-ProjectIssue.test.ps1 | 3 -- .../items/project_item_draftissue.test.ps1 | 3 -- Test/public/items/project_item_show.test.ps1 | 8 +--- Test/public/mockdatabase.test.ps1 | 2 - Test/public/project/addprojectuser.test.ps1 | 4 -- Test/public/project/getproject.test.ps1 | 8 ---- .../project/updateprojectrecent.test.ps1 | 15 ++----- .../projectDatabase/project_database.test.ps1 | 6 --- Test/public/project_fields_list.test.ps1 | 12 +----- .../project_item.searchprojectitem.test.ps1 | 19 +++------ Test/public/project_item.test.ps1 | 42 +++++-------------- Test/public/project_item_list.test.ps1 | 8 +--- Test/public/project_item_search.test.ps1 | 18 +------- Test/public/project_items_staged.test.ps1 | 39 +++-------------- .../project_items_staged_Async.test.ps1 | 36 ++-------------- .../public/repository/get-repository.test.ps1 | 6 +-- Test/traceInvoke.log | 1 + 32 files changed, 42 insertions(+), 259 deletions(-) diff --git a/Test/mockfiles.log b/Test/mockfiles.log index 5ab0797..e3acaf2 100644 --- a/Test/mockfiles.log +++ b/Test/mockfiles.log @@ -202,5 +202,9 @@ { "FileName": "invoke-UpdateProjectV2Collaborators-MDQ6VXNlcjY4ODQ0MDg=.json", "Command": "Invoke-UpdateProjectV2Collaborators -ProjectId PVT_kwDOAlIw4c4BCe3V -collaborators \"\" -Role \"WRITER\"" + }, + { + "FileName": "invoke-GitHubOrgProjectWithFields-octodemo-700-query-field-text.json", + "Command": "Invoke-GitHubOrgProjectWithFields -Owner octodemo -ProjectNumber 700 -afterFields \"\" -afterItems \"\" -query \"updated:<2025-03-15\"" } ] diff --git a/Test/public/driver/user/user.test.ps1 b/Test/public/driver/user/user.test.ps1 index 6587f56..12271db 100644 --- a/Test/public/driver/user/user.test.ps1 +++ b/Test/public/driver/user/user.test.ps1 @@ -1,6 +1,4 @@ function Test_GetUser_SUCCESS{ - Reset-InvokeCommandMock - Mock_DatabaseRoot Assert-NotImplemented } \ No newline at end of file diff --git a/Test/public/edit-sync-projectitem-comments.test.ps1 b/Test/public/edit-sync-projectitem-comments.test.ps1 index e3a556b..216f20d 100644 --- a/Test/public/edit-sync-projectitem-comments.test.ps1 +++ b/Test/public/edit-sync-projectitem-comments.test.ps1 @@ -1,7 +1,4 @@ function Test_Edit_Sync_ProjectItem_AddComments_Issue { - - Reset-InvokeCommandMock - Mock_DatabaseRoot $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number $i = $p.issue diff --git a/Test/public/environmentCache.test.ps1 b/Test/public/environmentCache.test.ps1 index a58da1c..3c8338d 100644 --- a/Test/public/environmentCache.test.ps1 +++ b/Test/public/environmentCache.test.ps1 @@ -4,9 +4,6 @@ function Test_EnvironmentCache{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - $p = Get-Mock_Project_700 ; $Owner = $p.owner ; $projectNumber = $p.number $i = $p.issue $f = $p.fieldtext @@ -18,8 +15,7 @@ function Test_EnvironmentCache{ MockCall_GetProject_700 -Cache # Reset mock calls - Reset-invokeCommandMock - Mock_DatabaseRoot -NotReset + Reset_Test_Mock -NoResetDatabase $itemId = $i.Id $fieldTitleValue = $i.title diff --git a/Test/public/getPrompt.test.ps1 b/Test/public/getPrompt.test.ps1 index 8a586f2..fae2b88 100644 --- a/Test/public/getPrompt.test.ps1 +++ b/Test/public/getPrompt.test.ps1 @@ -1,8 +1,5 @@ function Test_GetProjecthelperPrompt { - Reset-InvokeCommandMock - Mock_DatabaseRoot - $owner = "octodemo" $projectNumber = "625" $s = $ProjecthelperPromoptSettings diff --git a/Test/public/integrations/Edit-ProjectItemWithValues.test.ps1 b/Test/public/integrations/Edit-ProjectItemWithValues.test.ps1 index 18817c5..c7fcd5a 100644 --- a/Test/public/integrations/Edit-ProjectItemWithValues.test.ps1 +++ b/Test/public/integrations/Edit-ProjectItemWithValues.test.ps1 @@ -1,8 +1,6 @@ function Test_EditProjectItemWithValues_Integration { # Assert-SkipTest - Reset-InvokeCommandMock - Mock_DatabaseRoot $owner = "octodemo" $projectNumber = "625" diff --git a/Test/public/integrations/sync-ProjectItemsBetweenProjects.test.ps1 b/Test/public/integrations/sync-ProjectItemsBetweenProjects.test.ps1 index 3ab338f..cde1583 100644 --- a/Test/public/integrations/sync-ProjectItemsBetweenProjects.test.ps1 +++ b/Test/public/integrations/sync-ProjectItemsBetweenProjects.test.ps1 @@ -1,6 +1,4 @@ function Test_UpdateProjectItemsBetweenProjects{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $p625 = Get-Mock_Project_625 ; $owner0 = $p625.owner ; $projectNumber0 = $p625.number $p626 = Get-Mock_Project_626 ; $owner1 = $p626.owner ; $projectNumber1 = $p626.number @@ -38,8 +36,6 @@ function Test_UpdateProjectItemsBetweenProjects{ } function Test_UpdateProjectItemsBetweenProjects_NoRefresh_NoRefresh{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $p625 = Get-Mock_Project_625 ; $owner0 = $p625.owner ; $projectNumber0 = $p625.number $p626 = Get-Mock_Project_626 ; $owner1 = $p626.owner ; $projectNumber1 = $p626.number @@ -51,8 +47,7 @@ function Test_UpdateProjectItemsBetweenProjects_NoRefresh_NoRefresh{ MockCall_GetProject -MockProject $p626 -Cache # Reset mocks to fail if mocks are called again - Reset-InvokeCommandMock - Mock_DatabaseRoot -NotReset + Reset_Test_Mock -NoResetDatabase # Act @@ -75,8 +70,6 @@ function Test_UpdateProjectItemsBetweenProjects_NoRefresh_NoRefresh{ } function Test_SyncProjectItemsBetweenProjects_SameValues{ - Reset-InvokeCommandMock - Mock_DatabaseRoot MockCall_GetProject_700 $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number diff --git a/Test/public/integrations/update-ProjectImtesWithInjection.test.ps1 b/Test/public/integrations/update-ProjectImtesWithInjection.test.ps1 index 8e1bc60..7c988c4 100644 --- a/Test/public/integrations/update-ProjectImtesWithInjection.test.ps1 +++ b/Test/public/integrations/update-ProjectImtesWithInjection.test.ps1 @@ -2,9 +2,6 @@ function Test_UpdateProjectWithInjection{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - # https://github.com/orgs/octodemo/projects/625/views/1 $mp = Get-Mock_Project_625 ; $owner = $mp.owner ; $projectNumber = $mp.number @@ -87,9 +84,6 @@ function Test_UpdateProjectWithInjection{ function Test_UpdateProjectWithInjection_Failed_1{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - # https://github.com/orgs/octodemo/projects/625/views/1 $mp = Get-Mock_Project_625 ; $owner = $mp.owner ; $projectNumber = $mp.number @@ -165,9 +159,6 @@ function Test_UpdateProjectWithInjection_Failed_1{ function Test_InvokeProjectInjection{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - $owner = "octodemo" $projectNumber = "625" @@ -210,10 +201,7 @@ function Test_InvokeProjectInjection{ function Test_InvokeProjectInjection_Fail{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - - $owner = "octodemo" + $owner = "octodemo" $projectNumber = "625" MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName "invoke-GitHubOrgProjectWithFields-$owner-$projectNumber-skipitems.json" -SkipItems diff --git a/Test/public/integrations/update-ProjectItemsStatusOnDueDate.test.ps1 b/Test/public/integrations/update-ProjectItemsStatusOnDueDate.test.ps1 index 619d51d..6aadf28 100644 --- a/Test/public/integrations/update-ProjectItemsStatusOnDueDate.test.ps1 +++ b/Test/public/integrations/update-ProjectItemsStatusOnDueDate.test.ps1 @@ -1,8 +1,5 @@ function Test_UpdateProjectItemStatusOnDueDate { - Reset-InvokeCommandMock - Mock_DatabaseRoot - # Mock calling Toda MockCallToString -Command "Get-Date -Format yyyy-MM-dd" -OutString "2025-03-15" diff --git a/Test/public/integrations/update-ProjectItemsWithIntegration.test.ps1 b/Test/public/integrations/update-ProjectItemsWithIntegration.test.ps1 index 0eee1ad..cedde8b 100644 --- a/Test/public/integrations/update-ProjectItemsWithIntegration.test.ps1 +++ b/Test/public/integrations/update-ProjectItemsWithIntegration.test.ps1 @@ -1,8 +1,5 @@ function Test_UpdateProjectWithIntegration{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - $mp = Get-Mock_Project_625 ; $owner = $mp.owner ; $projectNumber = $mp.number Mockcall_GetProject -MockProject $mp $p = $mp.updateWithIntegration diff --git a/Test/public/interactive_test/getproject.test.ps1 b/Test/public/interactive_test/getproject.test.ps1 index d4ce89e..a54e28b 100644 --- a/Test/public/interactive_test/getproject.test.ps1 +++ b/Test/public/interactive_test/getproject.test.ps1 @@ -1,6 +1,4 @@ function Test_Get_Project_ItemId_Equal_Case_Sensitive { - Reset-InvokeCommandMock - Mock_DatabaseRoot $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number diff --git a/Test/public/issues/Add-IssuePullRequestComment.test.ps1 b/Test/public/issues/Add-IssuePullRequestComment.test.ps1 index 903150b..0d78d72 100644 --- a/Test/public/issues/Add-IssuePullRequestComment.test.ps1 +++ b/Test/public/issues/Add-IssuePullRequestComment.test.ps1 @@ -1,7 +1,5 @@ function Test_AddComment_SUCCESS_Using_Cache{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $p = Get-Mock_Project_700 ; $owner = $p.Owner ; $projectNumber = $p.Number $i = $p.Issue @@ -23,8 +21,6 @@ function Test_AddComment_SUCCESS_Using_Cache{ } function Test_AddComment_SUCCESS_Using_Direct{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $p = Get-Mock_Project_700 $i = $p.Issue @@ -44,8 +40,6 @@ function Test_AddComment_SUCCESS_Using_Direct{ } function Test_AddComment_SUCCESS_Using_Direct_PR{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $p = Get-Mock_Project_700 $i = $p.PullRequest diff --git a/Test/public/issues/Add-ProjectSubIssue.test.ps1 b/Test/public/issues/Add-ProjectSubIssue.test.ps1 index 640eb89..5405884 100644 --- a/Test/public/issues/Add-ProjectSubIssue.test.ps1 +++ b/Test/public/issues/Add-ProjectSubIssue.test.ps1 @@ -1,8 +1,5 @@ function Test_AddProjectSubIssue_SUCCESS{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - $p = Get-Mock_Project_700 ; $owner = $p.Owner ; $projectNumber = $p.Number @@ -51,9 +48,6 @@ function Test_AddProjectSubIssue_FAIL_ALREADY_HAS_PARENT { function Test_GetProjectSubIssue_SUCCESS { - Reset-InvokeCommandMock - Mock_DatabaseRoot - $p = Get-Mock_Project_700 ; $owner = $p.Owner ; $projectNumber = $p.Number $i = $p.subIssueToShow diff --git a/Test/public/issues/Get-ProjectIssue.test.ps1 b/Test/public/issues/Get-ProjectIssue.test.ps1 index 7a6150c..7983fd7 100644 --- a/Test/public/issues/Get-ProjectIssue.test.ps1 +++ b/Test/public/issues/Get-ProjectIssue.test.ps1 @@ -1,8 +1,5 @@ function Test_GetProjectIssue{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - $p = Get-Mock_Project_700 ; $Owner = $p.owner ; $projectNumber = $p.number $i = $p.issue diff --git a/Test/public/issues/New-ProjectIssue.test.ps1 b/Test/public/issues/New-ProjectIssue.test.ps1 index 68d6f08..4862b48 100644 --- a/Test/public/issues/New-ProjectIssue.test.ps1 +++ b/Test/public/issues/New-ProjectIssue.test.ps1 @@ -1,8 +1,5 @@ function Test_NewProjectIssueDirect{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - $p = Get-Mock_Project_700 $r = $p.repo $i = $p.issueToCreateAddAndRemove @@ -30,8 +27,6 @@ function Test_NewProjectIssueDirect{ } function Test_NewProjectIssue{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number $r = $p.repo diff --git a/Test/public/issues/Remove-ProjectIssue.test.ps1 b/Test/public/issues/Remove-ProjectIssue.test.ps1 index 3200e7a..58e4498 100644 --- a/Test/public/issues/Remove-ProjectIssue.test.ps1 +++ b/Test/public/issues/Remove-ProjectIssue.test.ps1 @@ -1,8 +1,5 @@ function Test_RemoveProjectIssue_SUCCESS { - Reset-InvokeCommandMock - Mock_DatabaseRoot - $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number $i = $p.issueToCreateAddAndRemove diff --git a/Test/public/items/project_item_draftissue.test.ps1 b/Test/public/items/project_item_draftissue.test.ps1 index 9cc7379..7e8b0c3 100644 --- a/Test/public/items/project_item_draftissue.test.ps1 +++ b/Test/public/items/project_item_draftissue.test.ps1 @@ -1,8 +1,5 @@ function Test_NewProjectDraftIssue { - Reset-InvokeCommandMock - Mock_DatabaseRoot - $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number MockCall_GetProject -MockProject $p diff --git a/Test/public/items/project_item_show.test.ps1 b/Test/public/items/project_item_show.test.ps1 index 0074309..20e28c0 100644 --- a/Test/public/items/project_item_show.test.ps1 +++ b/Test/public/items/project_item_show.test.ps1 @@ -62,9 +62,7 @@ function Get-Test_Write_Sucess_Factors { } Export-ModuleMember -Function Get-Test_Write_Sucess_Factors, Test_Write_Sucess function Test_ShowProjectItem_SUCESS{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - + $p = Get-Mock_Project_700 ; $Owner = $p.owner ; $ProjectNumber = $p.number $i = $p.issue MockCall_GetProject $p -skipItems @@ -90,9 +88,7 @@ function Test_ShowProjectItem_SUCESS{ } function Test_OpenInEditor{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - + $text = "Sample Text for Editor" $command = '"{content}" | code -w - ' diff --git a/Test/public/mockdatabase.test.ps1 b/Test/public/mockdatabase.test.ps1 index 7310733..a05ecbf 100644 --- a/Test/public/mockdatabase.test.ps1 +++ b/Test/public/mockdatabase.test.ps1 @@ -1,6 +1,4 @@ function Test_UpdateMock_DatabaseFileWithReplace{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number $cacheFileName = $p.cacheFileName diff --git a/Test/public/project/addprojectuser.test.ps1 b/Test/public/project/addprojectuser.test.ps1 index f345f39..fc3ec29 100644 --- a/Test/public/project/addprojectuser.test.ps1 +++ b/Test/public/project/addprojectuser.test.ps1 @@ -1,6 +1,4 @@ function Test_AddProjectUser_SUCCESS_SingleUser{ - Reset-InvokeCommandMock - Mock_DatabaseRoot # Enable-invokeCommandAliasModule # Invoke-UpdateProjectV2Collaborators -ProjectId PVT_kwDOAlIw4c4BCe3V -collaborators "MDQ6VXNlcjY4ODQ0MDg=" -Role "WRITER" @@ -25,8 +23,6 @@ function Test_AddProjectUser_SUCCESS_SingleUser{ } function Test_AddProjectUser_SUCCESS_MultipleUser{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $p =Get-Mock_Project_700 ; $owner = $p.Owner ; $projectNumber = $p.Number ; $projectId = $p.id MockCall_GetProject $p -SkipItems diff --git a/Test/public/project/getproject.test.ps1 b/Test/public/project/getproject.test.ps1 index efc8215..4529ce3 100644 --- a/Test/public/project/getproject.test.ps1 +++ b/Test/public/project/getproject.test.ps1 @@ -1,6 +1,4 @@ function Test_UpdateProject_Success{ - Reset-InvokeCommandMock - Mock_DatabaseRoot # enable-invokeCommandAliasModule @@ -22,8 +20,6 @@ function Test_UpdateProject_Success{ } function Test_UpdateProject_SkipItems_Success{ - Reset-InvokeCommandMock - Mock_DatabaseRoot # enable-invokeCommandAliasModule @@ -45,8 +41,6 @@ function Test_UpdateProject_SkipItems_Success{ } function Test_UpdateProject_With_Query_Success{ - Reset-InvokeCommandMock - Mock_DatabaseRoot # enable-invokeCommandAliasModule @@ -67,8 +61,6 @@ function Test_UpdateProject_With_Query_Success{ } function Test_UpdateProject_With_Query_Success_Update{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number $cacheFileName = $p.cacheFileName diff --git a/Test/public/project/updateprojectrecent.test.ps1 b/Test/public/project/updateprojectrecent.test.ps1 index 86db10a..b0c2a80 100644 --- a/Test/public/project/updateprojectrecent.test.ps1 +++ b/Test/public/project/updateprojectrecent.test.ps1 @@ -1,7 +1,5 @@ function Test_UpdateProject_SetsRecentUpdateToday_WhenQueryIsNull{ # Arrange - Reset-InvokeCommandMock - Mock_DatabaseRoot $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number $today = (Get-Mock_Today).today @@ -22,8 +20,6 @@ function Test_UpdateProject_SetsRecentUpdateToday_WhenQueryIsNull{ function Test_UpdateProjectRecent_FirstCAll_SetRecentUpdate_toToday{ # Arrange - Reset-InvokeCommandMock - Mock_DatabaseRoot Mock_Today $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number @@ -48,19 +44,14 @@ function Test_UpdateProjectRecent_FirstCAll_SetRecentUpdate_toToday{ function Test_UpdateProjectRecent_UpdateBasedOn_SetRecentUpdate{ # Arrange - Reset-InvokeCommandMock - $today = (Get-Mock_Today).today - MockCallToString -Command "Get-Date -Format yyyy-MM-dd" -OutString $today - # Cache project - Mock_DatabaseRoot MockCall_GetProject_700 -Cache - Reset-InvokeCommandMock - Mock_DatabaseRoot -NotReset - MockCallToString -Command "Get-Date -Format yyyy-MM-dd" -OutString $today + # Reset Mocks to ensure no mocks functions left from caching project + Reset_Test_Mock -NoResetDatabase $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number + $today = (Get-Mock_Today).today $query = "updated:<$today" # not real query just a mock file with some items reply $fileName = $p.getProjectWithQuery.getProjectWithQueryMockFile diff --git a/Test/public/projectDatabase/project_database.test.ps1 b/Test/public/projectDatabase/project_database.test.ps1 index 63cd51f..d385fe9 100644 --- a/Test/public/projectDatabase/project_database.test.ps1 +++ b/Test/public/projectDatabase/project_database.test.ps1 @@ -1,9 +1,6 @@ function Test_SaveProjectDatabase_SafeId_Flag_PrivateCall{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number MockCall_GetProject_700 @@ -29,9 +26,6 @@ function Test_SaveProjectDatabase_SafeId_Flag_PrivateCall{ function Test_SaveProjectDatabase_Safe_PrivateCall{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number MockCall_GetProject_700 diff --git a/Test/public/project_fields_list.test.ps1 b/Test/public/project_fields_list.test.ps1 index bfe35cd..8ecdb6b 100644 --- a/Test/public/project_fields_list.test.ps1 +++ b/Test/public/project_fields_list.test.ps1 @@ -1,8 +1,5 @@ function Test_GetProjectFields_SUCCESS_AllFields{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - $p = Get-Mock_Project_700 ; $owner = $p.Owner ; $projectNumber = $p.Number MockCall_GetProject -MockProject $p -SkipItems @@ -33,9 +30,6 @@ function Test_GetProjectFields_SUCCESS_AllFields{ function Test_GetProjectFields_Fail_Comments_Present{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - $p = Get-Mock_Project_700 ; $owner = $p.Owner ; $projectNumber = $p.Number MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName $p.projectFile_WrongField -SkipItems @@ -55,9 +49,6 @@ function Test_GetProjectFields_Fail_Comments_Present{ function Test_GetProjectFields_SUCCESS_FilterByName{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - $Owner = "SomeOrg" ; $ProjectNumber = 164 # title refrence with differnt case and spaces @@ -73,8 +64,7 @@ function Test_GetProjectFields_SUCCESS_FilterByName{ } function Test_GetProjectFields_SUCCESS_MoreInfo{ - Reset-InvokeCommandMock - Mock_DatabaseRoot + $Owner = "SomeOrg" ; $ProjectNumber = 164 MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'projectV2-skipitems.json' -SkipItems diff --git a/Test/public/project_item.searchprojectitem.test.ps1 b/Test/public/project_item.searchprojectitem.test.ps1 index 1c36e1b..f02703d 100644 --- a/Test/public/project_item.searchprojectitem.test.ps1 +++ b/Test/public/project_item.searchprojectitem.test.ps1 @@ -1,8 +1,7 @@ # Tests for Search-ProjectItem function Test_SearchProjectItem_Basic_SUCCESS { - Reset-InvokeCommandMock - Mock_DatabaseRoot + MockCall_GetProject_700 $p = Get-Mock_Project_700 @@ -24,8 +23,7 @@ function Test_SearchProjectItem_Basic_SUCCESS { } function Test_SearchProjectItem_PassThru_SUCCESS { - Reset-InvokeCommandMock - Mock_DatabaseRoot + MockCall_GetProject_700 $p = Get-Mock_Project_700 @@ -51,8 +49,7 @@ function Test_SearchProjectItem_PassThru_SUCCESS { } function Test_SearchProjectItem_SortByTitle_SUCCESS { - Reset-InvokeCommandMock - Mock_DatabaseRoot + MockCall_GetProject_700 $p = Get-Mock_Project_700 @@ -70,8 +67,7 @@ function Test_SearchProjectItem_SortByTitle_SUCCESS { } function Test_SearchProjectItem_CustomAttributes_SUCCESS { - Reset-InvokeCommandMock - Mock_DatabaseRoot + MockCall_GetProject_700 $p = Get-Mock_Project_700 @@ -91,8 +87,7 @@ function Test_SearchProjectItem_CustomAttributes_SUCCESS { } function Test_SearchProjectItem_NoMatch { - Reset-InvokeCommandMock - Mock_DatabaseRoot + MockCall_GetProject_700 $p = Get-Mock_Project_700 @@ -104,9 +99,7 @@ function Test_SearchProjectItem_NoMatch { } function Test_SearchProjectItem_AND_Filter_SUCCESS { - Reset-InvokeCommandMock - Mock_DatabaseRoot - + $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number $cacheFileName = $p.cacheFileName MockCall_GetProject $p -Cache diff --git a/Test/public/project_item.test.ps1 b/Test/public/project_item.test.ps1 index 425b917..b48be58 100644 --- a/Test/public/project_item.test.ps1 +++ b/Test/public/project_item.test.ps1 @@ -1,7 +1,5 @@ function Test_GetProjectItem_SUCCESS{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $p = Get-Mock_Project_700 ; $Owner = $p.owner ; $projectNumber = $p.number $i = $p.draftissue @@ -53,8 +51,7 @@ function Test_GetProjectItem_SUCCESS{ } function Test_GetProjectItem_Comments{ - Reset-InvokeCommandMock - Mock_DatabaseRoot + $p = Get-Mock_Project_700 ; $Owner = $p.owner ; $projectNumber = $p.number $i = $p.issue $itemId = $i.id @@ -75,8 +72,7 @@ function Test_GetProjectItem_Comments{ } function Test_GetProjectItem_Staged_Title{ - Reset-InvokeCommandMock - Mock_DatabaseRoot + $p = Get-Mock_Project_700 ; $Owner = $p.owner ; $projectNumber = $p.number $i = $p.issue $itemId = $i.id @@ -94,8 +90,7 @@ function Test_GetProjectItem_Staged_Title{ } function Test_GetProjectItem_Staged_Body{ - Reset-InvokeCommandMock - Mock_DatabaseRoot + $p = Get-Mock_Project_700 ; $Owner = $p.owner ; $projectNumber = $p.number $i = $p.issue $itemId = $i.id @@ -113,9 +108,7 @@ function Test_GetProjectItem_Staged_Body{ } function Test_TestProjectItem_Success{ - - Reset-InvokeCommandMock - Mock_DatabaseRoot + $p = Get-Mock_Project_700 ; $Owner = $p.owner ; $projectNumber = $p.number MockCall_GetProject $p -Cache @@ -133,8 +126,6 @@ function Test_TestProjectItem_Success{ } function Test_EditProjetItems_SUCCESS_Transformations{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $p = Get-Mock_Project_700 ; $Owner = $p.owner ; $ProjectNumber = $p.number MockCall_GetProject -MockProject $p -Cache @@ -158,8 +149,6 @@ function Test_EditProjetItems_SUCCESS_Transformations{ } function Test_EditProjectItems_SameValue{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $Owner = "octodemo" ; $ProjectNumber = 700 MockCall_GetProject_700 @@ -187,8 +176,7 @@ function Test_EditProjectItems_SameValue{ function Test_ResetProjectItem_Value_SUCCESS{ - Reset-InvokeCommandMock - Mock_DatabaseRoot + $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number $item = $p.issue ; $itemId = $item.id @@ -230,8 +218,7 @@ function Test_ResetProjectItem_Value_SUCCESS{ function Test_ResetProjectItem_SUCCESS{ - Reset-InvokeCommandMock - Mock_DatabaseRoot + $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number $item = $p.issue ; $itemId = $item.id @@ -265,8 +252,6 @@ function Test_ResetProjectItem_SUCCESS{ } function Test_EditProjectItems_Direct{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $Owner = "octodemo" ; $ProjectNumber = 700 @@ -297,8 +282,7 @@ function Test_UpdateProjectDatabase_Fail_With_Staged{ # When changes are staged list update should fail. # As Update-ProjectDatabase is a private function, we will test it through the public function Get-ProjectItems with Force - Reset-InvokeCommandMock - Mock_DatabaseRoot + MockCall_GetProject_700 $p = Get-Mock_Project_700 ; $Owner = $p.Owner ; $ProjectNumber = $p.Number @@ -339,9 +323,7 @@ function Test_UpdateProjectDatabase_Fail_With_Staged{ } function Test_GetItemDirect_SUCCESS{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - + $itemId = "PVTI_lADNJr_OADU3Ys4GAgVO" $itemUrl = "https://github.com/github/sales/issues/11742" $contentId ="I_kwDOAFbrpM6s_fNK" @@ -357,8 +339,6 @@ function Test_GetItemDirect_SUCCESS{ } function Test_AddProjectItemDirect_AlreadyMember{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $p = Get-Mock_Project_700 ; $Owner = $p.owner ; $ProjectNumber = $p.number $i = $p.issue @@ -373,8 +353,7 @@ function Test_AddProjectItemDirect_AlreadyMember{ function Test_ShowProjectItem_SUCCESS{ - Reset-InvokeCommandMock - Mock_DatabaseRoot + $p = Get-Mock_Project_700; $Owner = "octodemo" ; $ProjectNumber = 700 $i = $p.issue @@ -409,8 +388,7 @@ function Test_ShowProjectItem_SUCCESS{ function Test_ShowProjectItem_SUCCESS_Multiple{ - Reset-InvokeCommandMock - Mock_DatabaseRoot + MockCall_GetProject_700 $p = Get-Mock_Project_700; $Owner = $p.owner; $ProjectNumber = $p.number diff --git a/Test/public/project_item_list.test.ps1 b/Test/public/project_item_list.test.ps1 index 4818f3c..94e94b6 100644 --- a/Test/public/project_item_list.test.ps1 +++ b/Test/public/project_item_list.test.ps1 @@ -1,7 +1,6 @@ function Test_GetProjetItems_SUCCESS{ - Reset-InvokeCommandMock - Mock_DatabaseRoot + $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number $i = $p.issue @@ -52,8 +51,7 @@ function Test_GetProjetItems_SUCCESS{ function Test_GetProjetItems_FAIL{ - Reset-InvokeCommandMock - Mock_DatabaseRoot + $Owner = "SomeOrg" ; $ProjectNumber = 164 @@ -74,8 +72,6 @@ function Test_GetProjetItems_FAIL{ } function Test_ProjectItemList_ExcludeDone{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number $i = $p.issue diff --git a/Test/public/project_item_search.test.ps1 b/Test/public/project_item_search.test.ps1 index f31b1f7..ffcd17e 100644 --- a/Test/public/project_item_search.test.ps1 +++ b/Test/public/project_item_search.test.ps1 @@ -1,9 +1,6 @@ # call Search-ProjectItem with no parameters will return all the items function Test_SearchProjectItem_SUCCESS_NoParameters { - Reset-InvokeCommandMock - Mock_DatabaseRoot - MockCall_GetProject_700 $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number @@ -18,9 +15,6 @@ function Test_SearchProjectItem_SUCCESS_NoParameters { function Test_SearchProjectItem_SUCCESS_DefaultTitle{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - MockCall_GetProject_700 $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number @@ -40,9 +34,6 @@ function Test_SearchProjectItem_SUCCESS_DefaultTitle{ function Test_SearchProjectItem_SUCCESS_FieldName_Like{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - MockCall_GetProject_700 $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number @@ -56,8 +47,7 @@ function Test_SearchProjectItem_SUCCESS_FieldName_Like{ function Test_SearchProjectItem_SUCCESS_FieldName_Exact{ - Reset-InvokeCommandMock - Mock_DatabaseRoot + MockCall_GetProject_700 @@ -74,9 +64,6 @@ function Test_SearchProjectItem_SUCCESS_FieldName_Exact{ function Test_SearchProjectItem_SUCCESS_AnyField{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - MockCall_GetProject_700 $p = Get-Mock_Project_700; $owner = $p.owner ; $projectNumber = $p.number @@ -96,9 +83,6 @@ function Test_SearchProjectItem_SUCCESS_AnyField{ function Test_SearchProjectItem_FAIL{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - $Owner = "SomeOrg" ; $ProjectNumber = 164 $erroMessage= "Error: Project not found. Check owner and projectnumber" diff --git a/Test/public/project_items_staged.test.ps1 b/Test/public/project_items_staged.test.ps1 index 4d79332..c0832fa 100644 --- a/Test/public/project_items_staged.test.ps1 +++ b/Test/public/project_items_staged.test.ps1 @@ -1,7 +1,5 @@ function Test_SyncProjectItemsStaged_NoStaged { - Reset-InvokeCommandMock - Mock_DatabaseRoot $Owner = "SomeOrg" ; $ProjectNumber = 164 ; # $itemsCount = 12 ; $fieldsCount = 18 @@ -16,8 +14,6 @@ function Test_SyncProjectItemsStaged_NoStaged { } function Test_SyncProjectItemsStaged_SUCCESS_Number{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $Owner = "octodemo" ; $ProjectNumber = 700 $projectId = "PVT_kwDOAlIw4c4BCe3V" @@ -84,8 +80,6 @@ function Test_SyncProjectItemsStaged_SUCCESS_Number{ } function Test_SyncProjectItemsStaged_SUCCESS_Date{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $Owner = "octodemo" ; $ProjectNumber = 700 $projectId = "PVT_kwDOAlIw4c4BCe3V" @@ -149,8 +143,6 @@ function Test_SyncProjectItemsStaged_SUCCESS_Date{ } function Test_SyncProjectItemsStaged_SUCCESS_SingleSelect{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number @@ -231,8 +223,6 @@ function Test_SyncProjectItemsStaged_SUCCESS_SingleSelect{ } function Test_SyncProjectItemsStaged_SUCCESS_Content_Issue_NotCached { - Reset-InvokeCommandMock - Mock_DatabaseRoot $Owner = "octodemo" ; $ProjectNumber = 700 $projectId = "PVT_kwDOAlIw4c4BCe3V" @@ -324,8 +314,6 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_Issue_NotCached { } function Test_SyncProjectItemsStaged_SUCCESS_Content_PullRequest_NotCached { - Reset-InvokeCommandMock - Mock_DatabaseRoot $Owner = "octodemo" ; $ProjectNumber = 700 $projectId = "PVT_kwDOAlIw4c4BCe3V" @@ -417,8 +405,6 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_PullRequest_NotCached { } function Test_SyncProjectItemsStaged_SUCCESS_Content_DraftIssue_NotCached { - Reset-InvokeCommandMock - Mock_DatabaseRoot $Owner = "octodemo" ; $ProjectNumber = 700 $projectId = "PVT_kwDOAlIw4c4BCe3V" @@ -509,8 +495,6 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_DraftIssue_NotCached { } function Test_SyncProjectItemsStaged_SUCCESS_Content_Issue { - Reset-InvokeCommandMock - Mock_DatabaseRoot $Owner = "octodemo" ; $ProjectNumber = 700 @@ -520,8 +504,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_Issue { $project = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -Force $projectId = $project.ProjectId - Reset-InvokeCommandMock - Mock_DatabaseRoot -NotReset + Reset_Test_Mock -NoResetDatabase # project item issue $itemId1 = "PVTI_lADOAlIw4c4BCe3Vzgeio4o" @@ -603,8 +586,6 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_Issue { } function Test_SyncProjectItemsStaged_SUCCESS_Content_PullRequest { - Reset-InvokeCommandMock - Mock_DatabaseRoot $Owner = "octodemo" ; $ProjectNumber = 700 @@ -614,8 +595,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_PullRequest { $project = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -Force $projectId = $project.ProjectId - Reset-InvokeCommandMock - Mock_DatabaseRoot -NotReset + Reset_Test_Mock -NoResetDatabase # project item pull request $itemId1 = "PVTI_lADOAlIw4c4BCe3VzgeioBY" @@ -694,8 +674,6 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_PullRequest { } function Test_SyncProjectItemsStaged_SUCCESS_Content_DraftIssue { - Reset-InvokeCommandMock - Mock_DatabaseRoot $Owner = "octodemo" ; $ProjectNumber = 700 @@ -704,8 +682,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_DraftIssue { $project = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -Force $projectId = $project.ProjectId - Reset-InvokeCommandMock - Mock_DatabaseRoot -NotReset + Reset_Test_Mock -NoResetDatabase # project item draft issue $itemId1 = "PVTI_lADOAlIw4c4BCe3Vzgeiodc" @@ -788,8 +765,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_DraftIssue { function Test_ShowProjectItemsStaged { - Reset-InvokeCommandMock - Mock_DatabaseRoot + MockCall_GetProject_700 $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number @@ -869,8 +845,7 @@ function Test_ShowProjectItemsStaged { function Test_TestProjectItemStaged { - Reset-InvokeCommandMock - Mock_DatabaseRoot + $p = Get-Mock_Project_700 ; $Owner = $p.Owner ; $ProjectNumber = $p.Number $i = $p.issue @@ -933,8 +908,6 @@ function Test_SyncProjectItemsStagedAsync_debug { } function Test_Sync_ProjectDatabaseAsync_ClearValues{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $moduleRootPath = $PSScriptRoot | Split-Path -Parent | Split-Path -Parent | Convert-Path @@ -1006,8 +979,6 @@ function Test_Sync_ProjectDatabaseAsync_ClearValues{ } function Test_Sync_ProjectDatabase_ClearValues{ - Reset-InvokeCommandMock - Mock_DatabaseRoot $p = Get-Mock_Project_700 ; $Owner = $p.Owner ; $ProjectNumber = $p.Number $i = $p.issue diff --git a/Test/public/project_items_staged_Async.test.ps1 b/Test/public/project_items_staged_Async.test.ps1 index e6d2ff5..fb08cbc 100644 --- a/Test/public/project_items_staged_Async.test.ps1 +++ b/Test/public/project_items_staged_Async.test.ps1 @@ -1,8 +1,5 @@ function Test_SyncProjectItemsStaged_Async_NoStaged { - Reset-InvokeCommandMock - Mock_DatabaseRoot - $Owner = "SomeOrg" ; $ProjectNumber = 164 ; # $itemsCount = 12 ; $fieldsCount = 18 MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName 'projectV2.json' @@ -17,9 +14,6 @@ function Test_SyncProjectItemsStaged_Async_NoStaged { function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_Issue_NotCached { - Reset-InvokeCommandMock - Mock_DatabaseRoot - $modulePath = $MODULE_PATH | split-path -Parent $moduleTestPath = Join-Path -Path $modulePath -ChildPath 'Test' @@ -116,9 +110,6 @@ function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_Issue_NotCached { function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_PullRequest_NotCached { - Reset-InvokeCommandMock - Mock_DatabaseRoot - $modulePath = $MODULE_PATH | Split-Path -Parent $moduleTestPath = Join-Path -Path $modulePath -ChildPath 'Test' @@ -216,9 +207,6 @@ function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_PullRequest_NotCached function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_DraftIssue_NotCached { - Reset-InvokeCommandMock - Mock_DatabaseRoot - $modulePath = $MODULE_PATH | Split-Path -Parent $moduleTestPath = Join-Path -Path $modulePath -ChildPath 'Test' @@ -315,9 +303,6 @@ function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_DraftIssue_NotCached function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_Issue { - Reset-InvokeCommandMock - Mock_DatabaseRoot - $modulePath = $MODULE_PATH | split-path -Parent $moduleTestPath = Join-Path -Path $modulePath -ChildPath 'Test' @@ -329,8 +314,7 @@ function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_Issue { $project = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -Force $projectId = $project.ProjectId - Reset-InvokeCommandMock - Mock_DatabaseRoot -NotReset + Reset_Test_Mock -NoResetDatabase # project item issue $itemId1 = "PVTI_lADOAlIw4c4BCe3Vzgeio4o" @@ -419,9 +403,6 @@ function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_Issue { function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_PullRequest { - Reset-InvokeCommandMock - Mock_DatabaseRoot - $modulePath = $MODULE_PATH | Split-Path -Parent $moduleTestPath = Join-Path -Path $modulePath -ChildPath 'Test' @@ -433,8 +414,7 @@ function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_PullRequest { $projectId = $project.ProjectId # Reset mocks keeping DB - Reset-InvokeCommandMock - Mock_DatabaseRoot -NotReset + Reset_Test_Mock -NoResetDatabase # Pull request item $itemId1 = "PVTI_lADOAlIw4c4BCe3VzgeioBY" @@ -518,9 +498,6 @@ function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_PullRequest { function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_DraftIssue { - Reset-InvokeCommandMock - Mock_DatabaseRoot - $modulePath = $MODULE_PATH | Split-Path -Parent $moduleTestPath = Join-Path -Path $modulePath -ChildPath 'Test' @@ -532,8 +509,7 @@ function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_DraftIssue { $projectId = $project.ProjectId # Reset mocks keeping DB - Reset-InvokeCommandMock - Mock_DatabaseRoot -NotReset + Reset_Test_Mock -NoResetDatabase # Draft issue item $itemId1 = "PVTI_lADOAlIw4c4BCe3Vzgeiodc" @@ -643,9 +619,6 @@ function Test_SyncProjectItemsStaged_Async_debug { function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_Issue_AddComment { - Reset-InvokeCommandMock - Mock_DatabaseRoot - $modulePath = $MODULE_PATH | split-path -Parent $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number @@ -678,9 +651,6 @@ function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_Issue_AddComment { function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_PullRequest_AddComment { - Reset-InvokeCommandMock - Mock_DatabaseRoot - $modulePath = $MODULE_PATH | split-path -Parent $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number diff --git a/Test/public/repository/get-repository.test.ps1 b/Test/public/repository/get-repository.test.ps1 index a40a72b..a2d37cc 100644 --- a/Test/public/repository/get-repository.test.ps1 +++ b/Test/public/repository/get-repository.test.ps1 @@ -1,8 +1,5 @@ function Test_GetRepository{ - Reset-InvokeCommandMock - Mock_DatabaseRoot - $p = Get-Mock_Project_700 ; $r = $p.repo $ro = $p.repo.object @@ -24,8 +21,7 @@ function Test_GetRepository{ Assert-ItemExist -Path (Join-Path -Path $dbpath -ChildPath $dbname) # reset mocks and get repo to use cache - Reset-InvokeCommandMock - Mock_DatabaseRoot -NotReset + Reset_Test_Mock -NoResetDatabase $result = Get-Repository -Owner $r.owner -Name $r.name diff --git a/Test/traceInvoke.log b/Test/traceInvoke.log index 95513a3..2596077 100644 --- a/Test/traceInvoke.log +++ b/Test/traceInvoke.log @@ -78,3 +78,4 @@ Invoke-GetUser -Handle rulasg Invoke-UpdateProjectV2Collaborators -ProjectId PVT_kwDOAlIw4c4BCe3V -collaborators "MDQ6VXNlcjY4ODQ0MDg=" -Role "WRITER" Invoke-GetUser -Handle rauldibildos Invoke-UpdateProjectV2Collaborators -ProjectId PVT_kwDOAlIw4c4BCe3V -collaborators "MDQ6VXNlcjY4ODQ0MDg= U_kgDOC_E3gw" -Role "WRITER" +Invoke-GitHubOrgProjectWithFields -Owner octodemo -ProjectNumber 700 -afterFields "" -afterItems "" -query "updated:<2025-03-15"