-
-
Notifications
You must be signed in to change notification settings - Fork 7
Add tests to validate posts to the module route #37
Conversation
spec/unit/puppet_webhook_spec.rb
Outdated
it '/module returns ok' do | ||
stub_const('LOGGER', Logger.new('spec/fixtures/test.log')) | ||
basic_authorize('puppet', 'puppet') | ||
post '/module', { repository: { name: 'puppet-module'} }.to_json, { 'Content-Type' => 'application/json', 'X-Github-Event' => 'push' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also set headers this way.
header 'Content-Type', 'application/json'
header 'X-GitHub-Event', 'push'
post '/module', { repository: { name: 'puppet-module'} }.to_json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this could use some assertion about the response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The post body is missing owner: { login: 'login' }
so the parser chokes and the route never gets called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just use our github fixture?
post '/module', read_fixture('github/update.json')
spec/unit/puppet_webhook_spec.rb
Outdated
header 'Content-Type', 'application/json' | ||
header 'X-GitHub-Event', 'push' | ||
post '/module', { repository: { name: 'puppet-module', owner: { login: 'login' } } }.to_json | ||
expect(last_response).to be_ok |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this, otherwise the test now passes when it shouldn't (yet).
@dhollinger I pushed a couple of commits. Still needs work. It's now blowing up with puppet_webhook/lib/helpers/deployments.rb Line 36 in c14fa35
|
This will have to be reworked now to match #40 |
These tests will test the get routes for
/
and/heartbeat
. For now, I will be redirecting my focus on testing the helper methods rather than the post routes first. Those methods are more important to test rather than the post routes.Tests for the post routes will resume after the helpers are tested.