File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,4 +78,34 @@ function Test_GetProjectFields_SUCCESS_MoreInfo{
7878 Assert-Contains - Presented $result [0 ].MoreInfo - Expected " Todo"
7979 Assert-Contains - Presented $result [0 ].MoreInfo - Expected " In Progress"
8080 Assert-Contains - Presented $result [0 ].MoreInfo - Expected " Done"
81+ }
82+
83+ # Check that when calling Get-ProjectFields with -Force the Items are still there
84+ function Test_GetProjectFields_SUCCESS_ForceWithItems {
85+
86+ $p = Get-Mock_Project_700 ; $owner = $p.Owner ; $projectNumber = $p.Number
87+
88+ # Cache project and reset Mocks
89+ MockCall_GetProject $p - Cache
90+ Reset_Test_Mock - NoResetDatabase
91+
92+ # # Assert that items are cached
93+ $result = Get-Project - Owner $owner - ProjectNumber $projectNumber
94+ Assert-Count - Expected $p.items.totalCount - Presented $result.items
95+
96+ # Mock the call with SkipItems
97+ MockCall_GetProject $p - SkipItems
98+
99+ # Act
100+ $result = Get-ProjectFields - Owner $owner - ProjectNumber $projectNumber - Force
101+
102+ # Assert return items.
103+ Assert-Count - Expected $p.fields.totalCount - Presented $result
104+
105+ # Check that items are still there
106+ # As we do not set a mock it will
107+ $result = Get-Project - Owner $owner - ProjectNumber $projectNumber
108+ Assert-Count - Expected $p.items.totalCount - Presented $result.items
109+ Assert-Count - Expected $p.fields.totalCount - Presented $result.fields
110+
81111}
Original file line number Diff line number Diff line change @@ -98,6 +98,16 @@ function Update-ProjectDatabase {
9898 $items = $actualItems
9999 }
100100
101+ # If we are Skiping items on the update we need to keep the existing items in the database and just update the fields
102+ if ($SkipItems ){
103+ $actualprj = Get-ProjectFromDatabase - Owner $Owner - ProjectNumber $ProjectNumber
104+
105+ # Check if project has no items or the project is not cached yet
106+ $actualItems = $actualprj.items ?? $ (New-HashTable )
107+
108+ $items = $actualItems
109+ }
110+
101111 # Save ProjectV2 object to ProjectDatabase
102112 Save-ProjectV2toDatabase $projectV2 - Items $items - Fields $fields
103113
Original file line number Diff line number Diff line change @@ -19,9 +19,9 @@ function Get-Project {
1919
2020 $prj = Get-ProjectFromDatabase - Owner $Owner - ProjectNumber $ProjectNumber
2121
22- if ($SkipItems ){
23- $prj.Items = @ ()
24- }
22+ # if($SkipItems){
23+ # $prj.items = @()
24+ # }
2525
2626 return $prj
2727} Export-ModuleMember - Function Get-Project
You can’t perform that action at this time.
0 commit comments