Add unit tests for Notion block creation commands#78
Conversation
b847538
into
feature/36-pester-tests-for-block-functions
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting
| It "Should create an empty bookmark block" { | ||
| $result = New-NotionBookmarkBlock | ||
|
|
||
| $result | Should -BeOfType "notion_bookmark_block" | ||
| $result.type | Should -Be ([notion_blocktype]::bookmark) | ||
| $result.bookmark.url | Should -BeNullOrEmpty |
There was a problem hiding this comment.
[P1] Avoid null dereference when asserting empty bookmark block
The new test dereferences bookmark.url on a bookmark block created without parameters. New-NotionBookmarkBlock returns [notion_bookmark_block]::new() in this case and the class’s default constructor leaves the bookmark member uninitialized, so $result.bookmark is $null. Accessing .url will raise an InvokeMethodOnNull error before the Should -BeNullOrEmpty assertion is evaluated, causing the suite to fail even when the command behaves correctly. Consider asserting on $result.bookmark itself or initializing the bookmark structure in the cmdlet instead of dereferencing a possibly-null property.
Useful? React with 👍 / 👎.
Summary
Testing
./build.ps1 -Tasks test -AutoRestore(fails: pwsh not available in container)https://chatgpt.com/codex/tasks/task_e_68d54c277e6c8322880c72b8631cde17