Skip to content
This repository has been archived by the owner on Jan 29, 2022. It is now read-only.

Add tests to validate posts to the module route #37

Merged
merged 3 commits into from
Jun 24, 2018

Conversation

dhollinger
Copy link
Member

@dhollinger dhollinger commented Nov 28, 2017

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.

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' }
Copy link
Member

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

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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')

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
Copy link
Member

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).

@alexjfisher
Copy link
Member

@dhollinger I pushed a couple of commits. Still needs work. It's now blowing up with uninitialized constant Deployments::COMMAND_PREFIX here.

"#{COMMAND_PREFIX} r10k deploy module #{module_name}"

@alexjfisher alexjfisher mentioned this pull request Dec 2, 2017
@binford2k
Copy link
Member

This will have to be reworked now to match #40

@coveralls
Copy link

coveralls commented Jun 15, 2018

Coverage Status

Coverage increased (+0.8%) to 52.355% when pulling d316bdf on dhollinger:route_tests into aaf6f00 on voxpupuli:master.

@voxpupuli voxpupuli deleted a comment Jun 21, 2018
@dhollinger dhollinger changed the title WIP: Route tests Add tests to validate posts to the module route Jun 21, 2018
@bastelfreak bastelfreak merged commit 4b0c534 into voxpupuli:master Jun 24, 2018
@dhollinger dhollinger deleted the route_tests branch June 24, 2018 19:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants