Skip to content

Commit 0e6272d

Browse files
committed
fix(test): small fix of tets
1 parent ae47e19 commit 0e6272d

3 files changed

Lines changed: 39 additions & 16 deletions

File tree

Test/private/MockCall_Project700.ps1

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11

22
function Get-Mock_Project_700 {
33

4+
<#
5+
Reset-InvokeCommandMock
6+
Enable-InvokeCommandAliasModule
7+
$cmd = 'Invoke-GitHubOrgProjectWithFields -Owner octodemo -ProjectNumber 700 -afterFields "" -afterItems ""'
8+
save-invokeAsMockFile $cmd "invoke-GitHubOrgProjectWithFields-octodemo-700.json"
9+
#>
10+
411
$project = @{}
512

613
$project.projectFile = "invoke-GitHubOrgProjectWithFields-octodemo-700.json"
@@ -41,33 +48,47 @@ function Get-Mock_Project_700 {
4148

4249
# Issue for developer
4350
$issue = $pActual.items.nodes | Where-Object { $_.content.title -eq "Issue for development" }
51+
$fss = $issue.fieldValues.nodes | Where-Object { $_.field.id -eq $($fieldsingleselect.id) }
4452
$project.issue = @{
4553
id = $issue.id
4654
contentId = $issue.content.id
4755
title = $issue.content.title
4856
status = ($issue.fieldValues.nodes | Where-Object { $_.field.name -eq "Status" }).name
4957
fieldtext = ($issue.fieldValues.nodes | Where-Object { $_.field.id -eq $($fieldtext.id) }).text
58+
fieldsingleselect = @{
59+
name = $fss.name
60+
optionId = ($fss.field.options | where-object {$_.name -eq $fss.name}).Id
61+
}
5062
}
5163

5264
# PullRequest for developer
5365
$pullRequest = $pActual.items.nodes | Where-Object { $_.content.title -eq "PullRequest for development" }
66+
$fss = $pullRequest.fieldValues.nodes | Where-Object { $_.field.id -eq $($fieldsingleselect.id) }
5467
$project.pullrequest = @{
5568
id = $pullRequest.id
5669
contentId = $pullRequest.content.id
5770
title = $pullRequest.content.title
5871
status = ($pullRequest.fieldValues.nodes | Where-Object { $_.field.name -eq "Status" }).name
5972
fieldtext = ($pullRequest.fieldValues.nodes | Where-Object { $_.field.id -eq $($fieldtext.id) }).text
73+
fieldsingleselect = @{
74+
name = $fss.name
75+
optionId = ($fss.field.options | where-object {$_.name -eq $fss.name}).Id
76+
}
6077
}
6178

6279
# DraftIssue for developer
6380
$draftIssue = $pActual.items.nodes | Where-Object { $_.content.title -eq "DraftIssue for development" }
81+
$fss = $draftIssue.fieldValues.nodes | Where-Object { $_.field.id -eq $($fieldsingleselect.id) }
6482
$project.draftissue = @{
6583
id = $draftIssue.id
6684
contentId = $draftIssue.content.id
6785
title = $draftIssue.content.title
6886
status = ($draftIssue.fieldValues.nodes | Where-Object { $_.field.name -eq "Status" }).name
6987
fieldtext = ($draftIssue.fieldValues.nodes | Where-Object { $_.field.id -eq $($fieldtext.id) }).text
70-
88+
fieldsingleselect = @{
89+
name = $fss.name
90+
optionId = ($fss.field.options | where-object {$_.name -eq $fss.name}).Id
91+
}
7192
}
7293

7394
# Search tests

Test/private/mocks/invoke-GitHubOrgProjectWithFields-octodemo-700.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3571,7 +3571,7 @@
35713571
"id": "PR_kwDOPrRnkc6nndcE",
35723572
"body": "",
35733573
"title": "PullRequest for development",
3574-
"updatedAt": "2025-09-11T14:35:05Z",
3574+
"updatedAt": "2025-09-24T08:56:12Z",
35753575
"createdAt": "2025-09-09T13:56:05Z",
35763576
"number": 25,
35773577
"url": "https://github.com/octodemo/rulasg-dev-1/pull/25",
@@ -3853,7 +3853,7 @@
38533853
"id": "I_kwDOPrRnkc7KkwSq",
38543854
"body": "Body of issue for development",
38553855
"title": "Issue for development",
3856-
"updatedAt": "2025-09-11T13:06:24Z",
3856+
"updatedAt": "2025-09-24T08:29:13Z",
38573857
"createdAt": "2025-09-09T14:01:17Z",
38583858
"number": 26,
38593859
"url": "https://github.com/octodemo/rulasg-dev-1/issues/26",
@@ -3936,6 +3936,18 @@
39363936
"dataType": "NUMBER"
39373937
}
39383938
},
3939+
{
3940+
"__typename": "ProjectV2ItemFieldIterationValue",
3941+
"title": "field-iteration 3",
3942+
"startDate": "2025-10-05",
3943+
"duration": 14,
3944+
"field": {
3945+
"__typename": "ProjectV2IterationField",
3946+
"id": "PVTIF_lADOAlIw4c4BCe3Vzg0rhqQ",
3947+
"name": "field-iteration",
3948+
"dataType": "ITERATION"
3949+
}
3950+
},
39393951
{
39403952
"__typename": "ProjectV2ItemFieldTextValue",
39413953
"text": "text3",
@@ -3969,18 +3981,6 @@
39693981
}
39703982
]
39713983
}
3972-
},
3973-
{
3974-
"__typename": "ProjectV2ItemFieldIterationValue",
3975-
"title": "field-iteration 3",
3976-
"startDate": "2025-10-05",
3977-
"duration": 14,
3978-
"field": {
3979-
"__typename": "ProjectV2IterationField",
3980-
"id": "PVTIF_lADOAlIw4c4BCe3Vzg0rhqQ",
3981-
"name": "field-iteration",
3982-
"dataType": "ITERATION"
3983-
}
39843984
}
39853985
]
39863986
}

Test/public/project_items_staged.test.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ function Test_SyncProjectItemsStaged_SUCCESS_Number{
7575

7676
# Assert
7777
Assert-IsTrue -Condition $result
78+
7879
$staged = Get-ProjectItemStaged -Owner $Owner -ProjectNumber $ProjectNumber
7980
Assert-Count -Expected 0 -Presented $staged
81+
8082
$item1 = Get-ProjectItem -Owner $Owner -ProjectNumber $ProjectNumber -ItemId $itemId1
81-
Assert-AreEqual -Expected $fieldValueToUpdate -Presented $item1.$fieldName
83+
Assert-AreEqual -Expected $fieldValue -Presented $item1.$fieldName
8284
}
8385

8486
function Test_SyncProjectItemsStaged_SUCCESS_Date{

0 commit comments

Comments
 (0)