Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Test/public/project_fields_list.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,34 @@ function Test_GetProjectFields_SUCCESS_MoreInfo{
Assert-Contains -Presented $result[0].MoreInfo -Expected "Todo"
Assert-Contains -Presented $result[0].MoreInfo -Expected "In Progress"
Assert-Contains -Presented $result[0].MoreInfo -Expected "Done"
}

# Check that when calling Get-ProjectFields with -Force the Items are still there
function Test_GetProjectFields_SUCCESS_ForceWithItems{

$p = Get-Mock_Project_700 ; $owner = $p.Owner ; $projectNumber = $p.Number

# Cache project and reset Mocks
MockCall_GetProject $p -Cache
Reset_Test_Mock -NoResetDatabase

## Assert that items are cached
$result = Get-Project -Owner $owner -ProjectNumber $projectNumber
Assert-Count -Expected $p.items.totalCount -Presented $result.items

# Mock the call with SkipItems
MockCall_GetProject $p -SkipItems

# Act
$result = Get-ProjectFields -Owner $owner -ProjectNumber $projectNumber -Force

# Assert return items.
Assert-Count -Expected $p.fields.totalCount -Presented $result

# Check that items are still there
# As we do not set a mock it will
$result = Get-Project -Owner $owner -ProjectNumber $projectNumber
Assert-Count -Expected $p.items.totalCount -Presented $result.items
Assert-Count -Expected $p.fields.totalCount -Presented $result.fields

}
10 changes: 10 additions & 0 deletions private/projectDatabase/project_database_update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ function Update-ProjectDatabase {
$items = $actualItems
}

# If we are Skiping items on the update we need to keep the existing items in the database and just update the fields
if($SkipItems){
$actualprj = Get-ProjectFromDatabase -Owner $Owner -ProjectNumber $ProjectNumber

# Check if project has no items or the project is not cached yet
$actualItems = $actualprj.items ?? $(New-HashTable)

$items = $actualItems
}

# Save ProjectV2 object to ProjectDatabase
Save-ProjectV2toDatabase $projectV2 -Items $items -Fields $fields

Expand Down
6 changes: 3 additions & 3 deletions public/project/getproject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ function Get-Project {

$prj = Get-ProjectFromDatabase -Owner $Owner -ProjectNumber $ProjectNumber

if($SkipItems){
$prj.Items = @()
}
# if($SkipItems){
# $prj.items = @()
# }

return $prj
} Export-ModuleMember -Function Get-Project
Expand Down
Loading