Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pester Tests Should Mock API Calls #1

Open
cofonseca opened this issue Mar 18, 2017 · 4 comments
Open

Pester Tests Should Mock API Calls #1

cofonseca opened this issue Mar 18, 2017 · 4 comments

Comments

@cofonseca
Copy link
Owner

cofonseca commented Mar 18, 2017

Due to the current design of the Pester tests, each of the functions is actually being executed live during the test. For example, running a test against New-HipchatUser will actually create a new user in your HipChat environment. The test will then run Remove-HipchatUser to clean up after itself.

I would like to investigate somehow mocking a properly structured API response from Invoke-WebRequest, to ensure that functions aren't actually making changes to the environment. After all, we want to test the code itself, not the API.

I can't quite figure out how to structure the response correctly.

@cofonseca cofonseca changed the title Pester Tests Actually Run Each Function Pester Tests Should Mock API Calls Apr 2, 2017
@mdavis332
Copy link
Contributor

#11 Tried to contribute to this open item with the linked PR. I'm super-new to all this, so advanced apologies for things that don't look quite right or inadvertent slips of GitHub etiquette.

@cofonseca
Copy link
Owner Author

@mdavis332 no worries at all! You seem to be doing just fine so far :)

I'll test your PR tomorrow when I have a bit more time.

@omiossec
Copy link

omiossec commented Oct 2, 2018

I will try to create some Test
but I see that you only test the statuscode
no more to test ?

@cofonseca
Copy link
Owner Author

Hi @omiossec,

I am open to testing anything that you think might be relevant.

FYI, HipChat has been purchased by Slack and will be going away within the next few months, so it might not be worth spending time on this. If you would still like to, please feel free!

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants