Skip to content

Commit 6ddb522

Browse files
committed
Merge pull request github#232 from github/testpilot
Testpilot
2 parents 70f91c3 + edfe6a8 commit 6ddb522

File tree

3 files changed

+106
-0
lines changed

3 files changed

+106
-0
lines changed

docs/test_pilot

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
TestPilot CI
2+
======
3+
4+
TestPilot CI is a fully managed distributed Continuous Integration and Deployment Service
5+
for Ruby, Node.js, Clojure, Java, Python, and Scala applications.
6+
7+
Install Notes
8+
-------------
9+
10+
1. Create an account at http://testpilot.me
11+
2. Authorize TestPilot to connect with your Github account.
12+
3. After your repositories have been synced, activate the repository you want to test.
13+
TestPilot will automatically add necessary token above for your project, alternatively you can
14+
find the token under your account page at http://testpilot.me/my/account
15+
16+
4. Check the "Active" checkbox and click "Update Settings".
17+
5. Push some changes to this repository and TestPilot will automatically start your build process.
18+
6. You should receive an email from TestPilot once the build has completed
19+
20+
For more details about TestPilot, go to http://testpilot.me
21+
22+
Developer Notes
23+
---------------
24+
25+
data
26+
- token
27+

services/test_pilot.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class Service::TestPilot < Service
2+
string :token
3+
4+
def receive_push
5+
http.ssl[:verify] = false
6+
http.params.merge!(authentication_param)
7+
http_post test_pilot_url, :payload => payload.to_json
8+
end
9+
10+
def test_pilot_url
11+
"http://testpilot.me/callbacks/github"
12+
end
13+
14+
def token
15+
data['token'].to_s.strip
16+
end
17+
18+
def authentication_param
19+
if token.empty?
20+
raise_config_error "Needs a token"
21+
end
22+
23+
{:token => token}
24+
end
25+
end
26+

test/test_pilot_test.rb

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
require File.expand_path('../helper', __FILE__)
2+
3+
class TestPilotTest < Service::TestCase
4+
def setup
5+
@stubs = Faraday::Adapter::Test::Stubs.new
6+
@svc = service(data, payload)
7+
end
8+
9+
def service(*args)
10+
super Service::TestPilot, *args
11+
end
12+
13+
def data
14+
{
15+
'token' => 'TOKEN'
16+
}
17+
end
18+
19+
def test_reads_token_from_data
20+
assert_equal "TOKEN", @svc.token
21+
end
22+
23+
def test_constructs_post_receive_url
24+
assert_equal 'http://testpilot.me/callbacks/github',
25+
@svc.test_pilot_url
26+
end
27+
28+
def test_posts_payload
29+
@stubs.post '/callbacks/github' do |env|
30+
assert_equal env[:params]['token'], @svc.token
31+
assert_equal payload, JSON.parse(Rack::Utils.parse_query(env[:body])['payload'])
32+
end
33+
@svc.receive_push
34+
end
35+
36+
def test_it_raises_an_error_if_no_token_is_supplied
37+
data = {'token' => ''}
38+
svc = service(data, payload)
39+
assert_raises Service::ConfigurationError do
40+
svc.receive_push
41+
end
42+
end
43+
44+
def test_strips_whitespace_from_form_values
45+
data = {
46+
'token' => 'TOKEN '
47+
}
48+
49+
svc = service(data, payload)
50+
assert_equal 'TOKEN', svc.token
51+
end
52+
end
53+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy