Skip to content

Add tests to GitHubRepositories.tests.ps1 - #176

Merged
Howard Wolosky (HowardWolosky) merged 17 commits into
microsoft:masterfrom
giuseppecampanelli:githubrepositories-tests
Jun 3, 2020
Merged

Add tests to GitHubRepositories.tests.ps1#176
Howard Wolosky (HowardWolosky) merged 17 commits into
microsoft:masterfrom
giuseppecampanelli:githubrepositories-tests

Conversation

@giuseppecampanelli

@giuseppecampanelliGiuseppe Campanelli (giuseppecampanelli) commented May 21, 2020

Copy link
Copy Markdown
Contributor

Fixes#139
Add tests for GitHubRepositories.ps1 functions

Add tests for GitHubRepositories.ps1 functions
@HowardWolosky

Copy link
Copy Markdown
Contributor

Thanks, @themilanfan! I'll take a look at this over the weekend.

@HowardWoloskyHoward Wolosky (HowardWolosky) added the technical debt Work that was postponed by a previous change. label May 22, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the submission, @themilanfan! Much appreciated!

Are you sure that you ran this iteration of the tests? There are a number of issues with them that should have caused failures. I added notes for a lot of them, but then I stopped looking further.

Try merging in the most recent changes in master and then take a stab at updating these tests again and make sure that they all pass. It's possible that you have some local default configuration for DefaultOwnerName and DefaultRepositoryName which is confusing things, however Common.ps1 should have swapped that out with the default configuration during test execution.

I'll leave it to you to investigate these a bit more.

Looking forward to future updates.

Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Remove -Verbose, parenthesis, and s from Topics
@giuseppecampanelli

Copy link
Copy Markdown
ContributorAuthor

Pending merge of issue #174 once it's merged to master so I can add the missing -Confirm:$false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, @themilanfan. It looks like there are still some issues to address. I didn't thoroughly look through this yet. I suggest that you run the tests all locally as well in a clean PowerShell session to try and see some of the issues that I'm point out.

Thanks again for all your hard work. Looking forward to your next update!

Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Comment threadTests/GitHubRepositories.tests.ps1 Outdated
@giuseppecampanelli

Copy link
Copy Markdown
ContributorAuthor

Howard Wolosky (@HowardWolosky) Sorry I wasn't explicit, I plan on testing and fixing the kinks once #174 gets merged so I can include the missing -Confirm:$false. However, I will fix the other things you noticed in the meantime 😄 I'll make sure next time to be clear so I can help you avoid reviewing for nothing!

Added remaining -Confirm:$false following new merges that added -Confirm:$false functionality.
@giuseppecampanelli

Copy link
Copy Markdown
ContributorAuthor

[WIP] Pending testing

@giuseppecampanelli

Giuseppe Campanelli (giuseppecampanelli) commented Jun 2, 2020

Copy link
Copy Markdown
ContributorAuthor

Howard Wolosky (@HowardWolosky) almost all is fixed, I'm getting one error for a test involving clearing repository topics. Could it be a bug?

When i ran the Set-GitHubRepositoryTopic -OwnerName $ownerName -RepositoryName $repoName -Clear outside of the test case, I got the following:

Exception: /Users/user/dev/github/PowerShellForGitHub/GitHubCore.ps1:322 Line | 322 | throw $remoteErrors[0].Exception | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | {"message":"Invalid request.\n\nFor 'items', nil is not a string.","documentation_url":"https://developer.github.com/v3/repos#replace-all-topics-for-a-repository"}

@X-Guardian

Copy link
Copy Markdown
Contributor

@themilanfan, I've raised issue #215 for this bug and PR #216 to fix it.

@giuseppecampanelli

Copy link
Copy Markdown
ContributorAuthor

Howard Wolosky (@HowardWolosky) should be good for review following issue raised & PR from Simon Heather (@X-Guardian) (thanks!).

@HowardWolosky

Copy link
Copy Markdown
Contributor

Finding that bug (#215) is a fantastic outcome to this PR. I love that by writing some missing UT's we identified an actual bug in the module, and that we now have a UT to catch further regressions of that area in the future. Thanks again!

@giuseppecampanelli

Giuseppe Campanelli (giuseppecampanelli) commented Jun 3, 2020

Copy link
Copy Markdown
ContributorAuthor

Howard Wolosky (@HowardWolosky) can confirm all tests pass now since #216 was merged

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the great update.

Two minor fixes (one logic error, and one comment fix that I would have ignored if the logic error hadn't been there too) and this will be ready to go.

Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Comment threadTests/GitHubRepositories.tests.ps1 Outdated
Co-authored-by: Howard Wolosky <HowardWolosky@users.noreply.github.com>
Co-authored-by: Howard Wolosky <HowardWolosky@users.noreply.github.com>
@giuseppecampanelli

Copy link
Copy Markdown
ContributorAuthor

Changes committed 👍 Howard Wolosky (@HowardWolosky)

@HowardWolosky

Copy link
Copy Markdown
Contributor

/azp run PowerShellForGitHub-CI

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Running CI build now to verify, then will merge in. Thanks again!

@HowardWoloskyHoward Wolosky (HowardWolosky) added the tests A change related to the Pester tests for the module. label Jun 3, 2020
@HowardWolosky

Howard Wolosky (HowardWolosky) commented Jun 3, 2020

Copy link
Copy Markdown
Contributor

Your CI build failed due to static analysis failures:

##[warning]Tests\GitHubRepositories.tests.ps1(129,17): Warning : The variable 'repo' is assigned but never used.
##[warning]Tests\GitHubRepositories.tests.ps1(154,17): Warning : The variable 'repo' is assigned but never used.
##[warning]Tests\GitHubRepositories.tests.ps1(158,17): Warning : The variable 'delete' is assigned but never used.
##[warning]Tests\GitHubRepositories.tests.ps1(170,17): Warning : The variable 'newRepoName' is assigned but never used.
##[warning]Tests\GitHubRepositories.tests.ps1(193,17): Warning : The variable 'repo' is assigned but never used.
##[warning]Tests\GitHubRepositories.tests.ps1(217,17): Warning : The variable 'repo' is assigned but never used.
##[warning]Tests\GitHubRepositories.tests.ps1(242,17): Warning : The variable 'repo' is assigned but never used.
##[warning]Tests\GitHubRepositories.tests.ps1(265,17): Warning : The variable 'repo' is assigned but never used.

Please verify static analysis is passing before submitting your next update. Thanks!

@giuseppecampanelli

Copy link
Copy Markdown
ContributorAuthor

Howard Wolosky (@HowardWolosky) apologies, will be more careful for next one. I've followed the same method other tests use to avoid this issue. Ready to re-run

@HowardWolosky

Copy link
Copy Markdown
Contributor

Howard Wolosky (@HowardWolosky) apologies, will be more careful for next one. I've followed the same method other tests use to avoid this issue. Ready to re-run

No worries. We had a bunch that had snuck in over time that I recently addressed (#180). That's why I got the CI build healthy again...to help keep master clean. And it looks like #193 also just failed for static analysis failures too, so you're in good company.

Will kick off a new CI build now.

@HowardWolosky

Copy link
Copy Markdown
Contributor

/azp run PowerShellForGitHub-CI

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@HowardWolosky

Howard Wolosky (HowardWolosky) commented Jun 3, 2020

Copy link
Copy Markdown
Contributor

There was one failing test, but only on macOS, and it was in Project Cards (unrelated) which means that there was something flakey going on.

Expected strings to be the same, but they were different.
Expected length: 11
Actual length: 16
Strings differ at index 8.
Expected: 'TestCardTwo'
But was: 'TestCard_Updated'
Stack trace
at <ScriptBlock>, /Users/runner/runners/2.169.1/work/1/s/Tests/GitHubProjectCards.tests.ps1: line 157
157: $results[1].note | Should be $defaultCardTwo

Merging this in now. Thanks for all your efforts! 🎆

@HowardWolosky
Howard Wolosky (HowardWolosky) merged commit 742b853 into microsoft:masterJun 3, 2020
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

technical debtWork that was postponed by a previous change.testsA change related to the Pester tests for the module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhance UT's for GitHubRepositories.ps1

3 participants

@giuseppecampanelli@HowardWolosky@X-Guardian