go_cd_feed 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.rvmrc +1 -0
- data/.zeroci.yml +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +32 -0
- data/README.textile +36 -0
- data/Rakefile +39 -0
- data/bin/go_api_client +3 -0
- data/go_api_client.gemspec +27 -0
- data/lib/go_api_client.rb +60 -0
- data/lib/go_api_client/atom.rb +4 -0
- data/lib/go_api_client/atom/author.rb +42 -0
- data/lib/go_api_client/atom/entry.rb +34 -0
- data/lib/go_api_client/atom/feed.rb +44 -0
- data/lib/go_api_client/atom/feed_page.rb +49 -0
- data/lib/go_api_client/commit.rb +30 -0
- data/lib/go_api_client/helpers.rb +1 -0
- data/lib/go_api_client/helpers/simple_attribute_support.rb +11 -0
- data/lib/go_api_client/http_fetcher.rb +43 -0
- data/lib/go_api_client/job.rb +64 -0
- data/lib/go_api_client/pipeline.rb +49 -0
- data/lib/go_api_client/stage.rb +57 -0
- data/lib/go_api_client/user.rb +36 -0
- data/lib/go_api_client/version.rb +9 -0
- data/ssh_keys/git-ci.zeroci.com +27 -0
- data/ssh_keys/git-ci.zeroci.com.pub +1 -0
- data/ssh_keys/git-ssh +3 -0
- data/test/fixtures/building/job_1.xml +41 -0
- data/test/fixtures/building/job_2.xml +43 -0
- data/test/fixtures/building/job_3.xml +40 -0
- data/test/fixtures/building/job_4.xml +40 -0
- data/test/fixtures/building/pipeline_1.xml +45 -0
- data/test/fixtures/building/pipeline_2.xml +39 -0
- data/test/fixtures/building/pipeline_3.xml +71 -0
- data/test/fixtures/building/stages.xml +180 -0
- data/test/fixtures/building/stages_1.xml +16 -0
- data/test/fixtures/building/stages_2.xml +16 -0
- data/test/fixtures/building/stages_3.xml +16 -0
- data/test/fixtures/building/stages_4.xml +16 -0
- data/test/fixtures/job_1_console.log.txt +82 -0
- data/test/fixtures/job_2_console.log.txt +82 -0
- data/test/fixtures/jobs_1.xml +29 -0
- data/test/fixtures/jobs_2.xml +29 -0
- data/test/fixtures/jobs_with_no_properties.xml +42 -0
- data/test/fixtures/ordering/go/api/jobs/1.xml +29 -0
- data/test/fixtures/ordering/go/api/jobs/10.xml +31 -0
- data/test/fixtures/ordering/go/api/jobs/2.xml +29 -0
- data/test/fixtures/ordering/go/api/jobs/3.xml +29 -0
- data/test/fixtures/ordering/go/api/jobs/4.xml +29 -0
- data/test/fixtures/ordering/go/api/jobs/5.xml +29 -0
- data/test/fixtures/ordering/go/api/jobs/6.xml +29 -0
- data/test/fixtures/ordering/go/api/jobs/7.xml +31 -0
- data/test/fixtures/ordering/go/api/jobs/8.xml +31 -0
- data/test/fixtures/ordering/go/api/jobs/9.xml +31 -0
- data/test/fixtures/ordering/go/api/pipelines/defaultPipeline/1.xml +31 -0
- data/test/fixtures/ordering/go/api/pipelines/defaultPipeline/2.xml +26 -0
- data/test/fixtures/ordering/go/api/pipelines/defaultPipeline/3.xml +26 -0
- data/test/fixtures/ordering/go/api/pipelines/defaultPipeline/4.xml +27 -0
- data/test/fixtures/ordering/go/api/pipelines/defaultPipeline/5.xml +33 -0
- data/test/fixtures/ordering/go/api/pipelines/defaultPipeline/stages.xml +255 -0
- data/test/fixtures/ordering/go/api/stages/1.xml +14 -0
- data/test/fixtures/ordering/go/api/stages/10.xml +14 -0
- data/test/fixtures/ordering/go/api/stages/2.xml +14 -0
- data/test/fixtures/ordering/go/api/stages/3.xml +14 -0
- data/test/fixtures/ordering/go/api/stages/4.xml +14 -0
- data/test/fixtures/ordering/go/api/stages/5.xml +14 -0
- data/test/fixtures/ordering/go/api/stages/6.xml +14 -0
- data/test/fixtures/ordering/go/api/stages/7.xml +14 -0
- data/test/fixtures/ordering/go/api/stages/8.xml +14 -0
- data/test/fixtures/ordering/go/api/stages/9.xml +14 -0
- data/test/fixtures/pagination/stages.xml +636 -0
- data/test/fixtures/pagination/stages_before_7916973.xml +615 -0
- data/test/fixtures/pagination/stages_before_7959831.xml +615 -0
- data/test/fixtures/pipelines_1.xml +32 -0
- data/test/fixtures/stages.xml +63 -0
- data/test/fixtures/stages_1.xml +14 -0
- data/test/fixtures/stages_2.xml +14 -0
- data/test/fixtures/stages_empty.xml +9 -0
- data/test/go_api_client/atom/author_test.rb +27 -0
- data/test/go_api_client/atom/entry_test.rb +27 -0
- data/test/go_api_client/atom/feed_page_test.rb +41 -0
- data/test/go_api_client/atom/feed_test.rb +25 -0
- data/test/go_api_client/building_test.rb +38 -0
- data/test/go_api_client/commit_test.rb +38 -0
- data/test/go_api_client/job_test.rb +42 -0
- data/test/go_api_client/pipeline_test.rb +34 -0
- data/test/go_api_client/stage_test.rb +75 -0
- data/test/go_api_client/user_test.rb +27 -0
- data/test/test_helper.rb +31 -0
- metadata +272 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
|
3
|
+
<pipeline name="defaultPipeline" counter="99" label="1">
|
4
|
+
<link rel="self" href="http://localhost:8153/go/api/pipelines/defaultPipeline/1.xml"/>
|
5
|
+
<id><![CDATA[urn:x-go.studios.thoughtworks.com:job-id:defaultPipeline:1]]></id>
|
6
|
+
<scheduleTime>2012-02-23T17:16:15+05:30</scheduleTime>
|
7
|
+
<materials>
|
8
|
+
<material materialUri="http://localhost:8153/go/api/materials/1.xml" type="GitMaterial" url="git@github.com:oogabooga/zinger.git" branch="master">
|
9
|
+
<modifications>
|
10
|
+
<changeset changesetUri="http://localhost:8153/go/api/materials/1/changeset/9f77888d7a594699894a17f4d61fc9dfac3cfb74.xml">
|
11
|
+
<user><![CDATA[oogabooga <twgosaas@gmail.com>]]></user>
|
12
|
+
<checkinTime>2012-02-21T15:41:30+05:30</checkinTime>
|
13
|
+
<revision><![CDATA[9f77888d7a594699894a17f4d61fc9dfac3cfb74]]></revision>
|
14
|
+
<message><![CDATA[Update README]]></message>
|
15
|
+
<file name="README" action="modified"/>
|
16
|
+
</changeset>
|
17
|
+
<changeset changesetUri="http://localhost:8153/go/api/materials/1/changeset/ded20c6210172daee9c100364679e65bded20c6210172daee9c10036467.xml">
|
18
|
+
<user><![CDATA[Ketan Padegaonkar <KetanPadegaonkar@gmail.com>]]></user>
|
19
|
+
<checkinTime>2012-02-23T15:42:10+05:30</checkinTime>
|
20
|
+
<revision><![CDATA[ded20c6210172daee9c100364679e65bded20c6210172daee9c10036467]]></revision>
|
21
|
+
<message><![CDATA[Fixed build]]></message>
|
22
|
+
<file name="Rakefile" action="modified"/>
|
23
|
+
</changeset>
|
24
|
+
</modifications>
|
25
|
+
</material>
|
26
|
+
</materials>
|
27
|
+
<stages>
|
28
|
+
<stage href="http://localhost:8153/go/api/stages/1.xml"/>
|
29
|
+
<stage href="http://localhost:8153/go/api/stages/2.xml"/>
|
30
|
+
</stages>
|
31
|
+
<approvedBy><![CDATA[changes]]></approvedBy>
|
32
|
+
</pipeline>
|
@@ -0,0 +1,63 @@
|
|
1
|
+
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:go="http://www.thoughtworks-studios.com/ns/go">
|
2
|
+
<title><![CDATA[defaultPipeline]]></title>
|
3
|
+
<id>http://localhost:8153/go/api/pipelines/defaultPipeline/stages.xml</id>
|
4
|
+
<author>
|
5
|
+
<name>Go</name>
|
6
|
+
</author>
|
7
|
+
<updated>2012-02-23T17:19:31+05:30</updated>
|
8
|
+
<link rel="self" href="http://localhost:8153/go/api/pipelines/defaultPipeline/stages.xml"/>
|
9
|
+
|
10
|
+
|
11
|
+
<!-- <link rel="next" href="http://localhost:8153/go/api/pipelines/defaultPipeline/stages.xml?before=6"/> -->
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
<entry>
|
16
|
+
<title><![CDATA[defaultPipeline(1) stage Acceptance(1) Failed]]></title>
|
17
|
+
<updated>2012-02-23T17:19:31+05:30</updated>
|
18
|
+
<id>http://localhost:8153/go/pipelines/defaultPipeline/1/Acceptance/1</id>
|
19
|
+
|
20
|
+
|
21
|
+
<author>
|
22
|
+
<name><![CDATA[oogabooga <twgosaas@gmail.com>]]></name>
|
23
|
+
</author>
|
24
|
+
|
25
|
+
|
26
|
+
<link title="Acceptance Stage Detail" href="http://localhost:8153/go/api/stages/2.xml" rel="alternate" type="application/vnd.go+xml"/>
|
27
|
+
<link title="Acceptance Stage Detail" href="http://localhost:8153/go/pipelines/defaultPipeline/1/Acceptance/1" rel="alternate" type="text/html"/>
|
28
|
+
|
29
|
+
<link title="defaultPipeline Pipeline Detail" href="http://localhost:8153/go/api/pipelines/defaultPipeline/1.xml" rel="http://www.thoughtworks-studios.com/ns/relations/go/pipeline" type="application/vnd.go+xml"/>
|
30
|
+
<link title="defaultPipeline Pipeline Detail" href="http://localhost:8153/go/pipelines/defaultPipeline/1/Acceptance/1/pipeline" rel="http://www.thoughtworks-studios.com/ns/relations/go/pipeline" type="text/html"/>
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
<category scheme="http://www.thoughtworks-studios.com/ns/categories/go" term="stage" label="Stage" />
|
35
|
+
<category scheme="http://www.thoughtworks-studios.com/ns/categories/go" term="completed" label="Completed" />
|
36
|
+
<category scheme="http://www.thoughtworks-studios.com/ns/categories/go" term="failed" label="Failed" />
|
37
|
+
</entry>
|
38
|
+
|
39
|
+
<entry>
|
40
|
+
<title><![CDATA[defaultPipeline(1) stage Units(1) Failed]]></title>
|
41
|
+
<updated>2012-02-23T17:16:41+05:30</updated>
|
42
|
+
<id>http://localhost:8153/go/pipelines/defaultPipeline/1/Units/1</id>
|
43
|
+
|
44
|
+
|
45
|
+
<author>
|
46
|
+
<name><![CDATA[oogabooga <twgosaas@gmail.com>]]></name>
|
47
|
+
</author>
|
48
|
+
|
49
|
+
|
50
|
+
<link title="Units Stage Detail" href="http://localhost:8153/go/api/stages/1.xml" rel="alternate" type="application/vnd.go+xml"/>
|
51
|
+
<link title="Units Stage Detail" href="http://localhost:8153/go/pipelines/defaultPipeline/1/Units/1" rel="alternate" type="text/html"/>
|
52
|
+
|
53
|
+
<link title="defaultPipeline Pipeline Detail" href="http://localhost:8153/go/api/pipelines/defaultPipeline/1.xml" rel="http://www.thoughtworks-studios.com/ns/relations/go/pipeline" type="application/vnd.go+xml"/>
|
54
|
+
<link title="defaultPipeline Pipeline Detail" href="http://localhost:8153/go/pipelines/defaultPipeline/1/Units/1/pipeline" rel="http://www.thoughtworks-studios.com/ns/relations/go/pipeline" type="text/html"/>
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
<category scheme="http://www.thoughtworks-studios.com/ns/categories/go" term="stage" label="Stage" />
|
59
|
+
<category scheme="http://www.thoughtworks-studios.com/ns/categories/go" term="completed" label="Completed" />
|
60
|
+
<category scheme="http://www.thoughtworks-studios.com/ns/categories/go" term="failed" label="Failed" />
|
61
|
+
</entry>
|
62
|
+
|
63
|
+
</feed>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
|
3
|
+
<stage name="Units" counter="1">
|
4
|
+
<link rel="self" href="http://localhost:8153/go/api/stages/1.xml"/>
|
5
|
+
<id><![CDATA[urn:x-go.studios.thoughtworks.com:stage-id:defaultPipeline:1:Units:1]]></id>
|
6
|
+
<pipeline name="defaultPipeline" counter="1" label="1" href="http://localhost:8153/go/api/pipelines/defaultPipeline/1.xml"/>
|
7
|
+
<updated>2012-02-23T17:16:41+05:30</updated>
|
8
|
+
<result>Failed</result>
|
9
|
+
<state>Completed</state>
|
10
|
+
<approvedBy><![CDATA[changes]]></approvedBy>
|
11
|
+
<jobs>
|
12
|
+
<job href="http://localhost:8153/go/api/jobs/1.xml"/>
|
13
|
+
</jobs>
|
14
|
+
</stage>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
|
3
|
+
<stage name="Acceptance" counter="1">
|
4
|
+
<link rel="self" href="http://localhost:8153/go/api/stages/2.xml"/>
|
5
|
+
<id><![CDATA[urn:x-go.studios.thoughtworks.com:stage-id:defaultPipeline:1:Acceptance:1]]></id>
|
6
|
+
<pipeline name="defaultPipeline" counter="1" label="1" href="http://localhost:8153/go/api/pipelines/defaultPipeline/1.xml"/>
|
7
|
+
<updated>2012-02-23T17:19:31+05:30</updated>
|
8
|
+
<result>Failed</result>
|
9
|
+
<state>Completed</state>
|
10
|
+
<approvedBy><![CDATA[anonymous]]></approvedBy>
|
11
|
+
<jobs>
|
12
|
+
<job href="http://localhost:8153/go/api/jobs/2.xml"/>
|
13
|
+
</jobs>
|
14
|
+
</stage>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:go="http://www.thoughtworks-studios.com/ns/go">
|
2
|
+
<title><![CDATA[defaultPipeline]]></title>
|
3
|
+
<id>http://localhost:8153/go/api/pipelines/defaultPipeline/stages.xml</id>
|
4
|
+
<author>
|
5
|
+
<name>Go</name>
|
6
|
+
</author>
|
7
|
+
<updated>2012-03-07T11:15:10+05:30</updated>
|
8
|
+
<link rel="self" href="http://localhost:8153/go/api/pipelines/defaultPipeline/stages.xml"/>
|
9
|
+
</feed>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
module Atom
|
5
|
+
class AuthorTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
test "should be able to parse author's info" do
|
8
|
+
doc = Nokogiri::XML(%Q{<author xmlns="http://www.w3.org/2005/Atom"><name><![CDATA[oogabooga <twgosaas@gmail.com>]]></name><uri>http://oogabooga.example.com<uri></author>})
|
9
|
+
author = Author.new(doc.root).parse!
|
10
|
+
assert_equal Author.new(nil, :name => 'oogabooga', :email => 'twgosaas@gmail.com', :uri => 'http://oogabooga.example.com'), author
|
11
|
+
end
|
12
|
+
|
13
|
+
test "should be able to parse author xml with no email and uri" do
|
14
|
+
doc = Nokogiri::XML(%Q{<author xmlns="http://www.w3.org/2005/Atom"><name><![CDATA[oogabooga]]></name></author>})
|
15
|
+
author = Author.new(doc.root).parse!
|
16
|
+
assert_equal Author.new(nil, :name => 'oogabooga'), author
|
17
|
+
end
|
18
|
+
|
19
|
+
test "should be able to parse author xml with email specified in the name tag" do
|
20
|
+
doc = Nokogiri::XML(%Q{<author xmlns="http://www.w3.org/2005/Atom"><name><![CDATA[oogabooga <twgosaas@gmail.com>]]></name></author>})
|
21
|
+
author = Author.new(doc.root).parse!
|
22
|
+
assert_equal Author.new(nil, :name => 'oogabooga', :email => 'twgosaas@gmail.com'), author
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
module Atom
|
5
|
+
class EntryTest < Test::Unit::TestCase
|
6
|
+
setup do
|
7
|
+
doc = Nokogiri::XML(file_contents('pagination/stages.xml'))
|
8
|
+
@root = doc.root
|
9
|
+
@entry_node = @root.xpath('./xmlns:entry')[12]
|
10
|
+
end
|
11
|
+
|
12
|
+
test "should parse entry node" do
|
13
|
+
entry = Entry.new(@entry_node).parse!
|
14
|
+
assert_equal 'https://go-server.example.com/go/pipelines/tlb/177/ant_count_go/1', entry.id
|
15
|
+
assert_equal Time.parse('2012-01-22 11:32:57 UTC'), entry.updated_at
|
16
|
+
assert_equal 'tlb(177) stage ant_count_go(1) Passed', entry.title
|
17
|
+
assert_equal 'https://go-server.example.com/go/api/stages/210161.xml', entry.stage_href
|
18
|
+
expected_authors = [
|
19
|
+
Author.new(nil, :name => 'Pavan', :email => 'itspanzi@gmail.com'),
|
20
|
+
Author.new(nil, :name => 'Pavan Sudarshan', :email => 'itspanzi@gmail.com')
|
21
|
+
]
|
22
|
+
|
23
|
+
assert_equal expected_authors, entry.authors
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
module Atom
|
5
|
+
class FeedPageTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
setup do
|
8
|
+
doc = Nokogiri::XML(file_contents("pagination/stages.xml"))
|
9
|
+
@feed_page = FeedPage.new(doc.root).parse!
|
10
|
+
end
|
11
|
+
|
12
|
+
test "should be able to parse one page of the paginated Go atom feed" do
|
13
|
+
assert_equal 25, @feed_page.entries.count
|
14
|
+
assert_equal 'https://go-server.example.com/go/api/pipelines/tlb/stages.xml', @feed_page.url
|
15
|
+
assert_equal 'https://go-server.example.com/go/api/pipelines/tlb/stages.xml?before=7959831', @feed_page.next_page
|
16
|
+
assert_equal Time.parse('2012-04-17 10:56:53 UTC'), @feed_page.updated_at
|
17
|
+
end
|
18
|
+
|
19
|
+
test "should answer if an entry id is present in the feed page" do
|
20
|
+
assert @feed_page.contains_entry?(@feed_page.entries[5].id)
|
21
|
+
assert_false @feed_page.contains_entry?("foo")
|
22
|
+
end
|
23
|
+
|
24
|
+
test "should answer if an entry object is present in the feed page" do
|
25
|
+
assert @feed_page.contains_entry?(@feed_page.entries[5])
|
26
|
+
assert_false @feed_page.contains_entry?(Entry.new(nil))
|
27
|
+
end
|
28
|
+
|
29
|
+
test "should return entries after a particular entry (top entries in feed)" do
|
30
|
+
entry = @feed_page.entries[5]
|
31
|
+
|
32
|
+
assert_equal @feed_page.entries_after(entry.id), @feed_page.entries_after(entry)
|
33
|
+
|
34
|
+
assert_equal 5, @feed_page.entries_after(entry.id).count
|
35
|
+
assert_equal 5, @feed_page.entries_after(entry).count
|
36
|
+
|
37
|
+
assert_false @feed_page.entries_after(entry).include?(entry)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
module Atom
|
5
|
+
class FeedTest < Test::Unit::TestCase
|
6
|
+
setup do
|
7
|
+
stub_request(:get, "https://go-server.example.com/go/api/pipelines/tlb/stages.xml").to_return(:body => file_contents("pagination/stages.xml"))
|
8
|
+
stub_request(:get, "https://go-server.example.com/go/api/pipelines/tlb/stages.xml?before=7959831").to_return(:body => file_contents("pagination/stages_before_7959831.xml"))
|
9
|
+
end
|
10
|
+
|
11
|
+
test "should stop at last seen atom entry id" do
|
12
|
+
feed = GoApiClient::Atom::Feed.new('https://go-server.example.com/go/api/pipelines/tlb/stages.xml', 'https://go-server.example.com/go/pipelines/tlb/175/ant_count_tlb/1').fetch!
|
13
|
+
assert_equal (25+4), feed.entries.count
|
14
|
+
end
|
15
|
+
|
16
|
+
test "should stop at first page if entry id not specified" do
|
17
|
+
stub_request(:get, "https://go-server.example.com/go/api/pipelines/tlb/stages.xml?before=7916973").to_return(:body => file_contents("pagination/stages_before_7916973.xml"))
|
18
|
+
|
19
|
+
feed = GoApiClient::Atom::Feed.new('https://go-server.example.com/go/api/pipelines/tlb/stages.xml').fetch!
|
20
|
+
assert_equal 25*3, feed.entries.count
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
class BuildingTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
test "should report that Go is building if atleast 1 project is building" do
|
7
|
+
feed = %Q{
|
8
|
+
<?xml version="1.0" encoding="utf-8"?>
|
9
|
+
<Projects>
|
10
|
+
<Project name="defaultPipeline :: RailsTests" activity="Building" lastBuildStatus="Success" lastBuildLabel="4" lastBuildTime="2012-07-19T10:03:04" webUrl="http://go-server.2.project:8153/go/pipelines/defaultPipeline/5/RailsTests/1" />
|
11
|
+
<Project name="defaultPipeline :: RailsTests :: Test" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="4" lastBuildTime="2012-07-19T10:03:04" webUrl="http://go-server.2.project:8153/go/tab/build/detail/defaultPipeline/5/RailsTests/1/Test" />
|
12
|
+
</Projects>
|
13
|
+
}
|
14
|
+
stub_request(:get, "http://go-server.2.project:8153/go/cctray.xml").
|
15
|
+
to_return(:body => feed)
|
16
|
+
assert GoApiClient.build_in_progress?(:host => 'go-server.2.project')
|
17
|
+
end
|
18
|
+
|
19
|
+
test "should report that Go is sleeping if all projects are sleeping" do
|
20
|
+
feed = %Q{
|
21
|
+
<?xml version="1.0" encoding="utf-8"?>
|
22
|
+
<Projects>
|
23
|
+
<Project name="defaultPipeline :: RailsTests" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="4" lastBuildTime="2012-07-19T10:03:04" webUrl="http://go-server.2.project:8153/go/pipelines/defaultPipeline/5/RailsTests/1" />
|
24
|
+
<Project name="defaultPipeline :: RailsTests :: Test" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="4" lastBuildTime="2012-07-19T10:03:04" webUrl="http://go-server.2.project:8153/go/tab/build/detail/defaultPipeline/5/RailsTests/1/Test" />
|
25
|
+
</Projects>
|
26
|
+
}
|
27
|
+
stub_request(:get, "http://go-server.2.project:8153/go/cctray.xml").
|
28
|
+
to_return(:body => feed)
|
29
|
+
assert_false GoApiClient.build_in_progress?(:host => 'go-server.2.project')
|
30
|
+
end
|
31
|
+
|
32
|
+
test "should handle empty feeds" do
|
33
|
+
stub_request(:get, "http://go-server.2.project:8153/go/cctray.xml").
|
34
|
+
to_return(:body => nil)
|
35
|
+
assert_false GoApiClient.build_in_progress?(:host => 'go-server.2.project')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
class CommitTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
test "should parse a changeset xml node" do
|
7
|
+
doc = Nokogiri::XML.parse %q{<changeset changesetUri="http://localhost:8153/go/api/materials/1/changeset/9f77888d7a594699894a17f4d61fc9dfac3cfb74.xml">
|
8
|
+
<bar>
|
9
|
+
<revision>jhgasdfjkhgads</revision>
|
10
|
+
<message>some message</message>
|
11
|
+
<checkinTime>unparsable cruft</checkinTime>
|
12
|
+
<user>unparsable cruft</user>
|
13
|
+
</bar>
|
14
|
+
|
15
|
+
<user><![CDATA[oogabooga <twgosaas@gmail.com>]]></user>
|
16
|
+
<checkinTime>2012-02-21T15:41:30+05:30</checkinTime>
|
17
|
+
<revision><![CDATA[9f77888d7a594699894a17f4d61fc9dfac3cfb74]]></revision>
|
18
|
+
<message><![CDATA[Update README]]></message>
|
19
|
+
<file name="README" action="modified"/>
|
20
|
+
<foo>
|
21
|
+
<revision>jhgasdfjkhgads</revision>
|
22
|
+
<message>some message</message>
|
23
|
+
<checkinTime>unparsable cruft</checkinTime>
|
24
|
+
<user>unparsable cruft</user>
|
25
|
+
</foo>
|
26
|
+
</changeset>
|
27
|
+
}
|
28
|
+
|
29
|
+
commit = Commit.new(doc.root).parse!
|
30
|
+
|
31
|
+
assert_equal '9f77888d7a594699894a17f4d61fc9dfac3cfb74', commit.revision
|
32
|
+
assert_equal 'Update README', commit.message
|
33
|
+
assert_equal Time.parse("2012-02-21 10:11:30 UTC"), commit.time
|
34
|
+
assert_equal User.parse("oogabooga <twgosaas@gmail.com>"), commit.user
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
class JobTest < Test::Unit::TestCase
|
5
|
+
test "should fetch the job xml and populate itself" do
|
6
|
+
stub_request(:get, "http://localhost:8153/go/api/jobs/1.xml").to_return(:body => file_contents("jobs_1.xml"))
|
7
|
+
|
8
|
+
link = "http://localhost:8153/go/api/jobs/1.xml"
|
9
|
+
job = GoApiClient::Job.from(link)
|
10
|
+
|
11
|
+
assert_equal 'http://localhost:8153/go/api/jobs/1.xml', job.url
|
12
|
+
assert_equal 'http://localhost:8153/go/files/defaultPipeline/1/Units/1/Test', job.artifacts_uri
|
13
|
+
assert_equal 'http://localhost:8153/go/files/defaultPipeline/1/Units/1/Test/cruise-output/console.log', job.console_log_url
|
14
|
+
|
15
|
+
|
16
|
+
assert_equal 'urn:x-go.studios.thoughtworks.com:job-id:defaultPipeline:1:Units:1:Test', job.identifier
|
17
|
+
|
18
|
+
assert_equal 900, job.duration
|
19
|
+
assert_equal "Test", job.name
|
20
|
+
assert_equal "Failed", job.result
|
21
|
+
assert_equal Time.parse('2012-02-23 11:46:15 UTC'), job.scheduled
|
22
|
+
assert_equal Time.parse('2012-02-23 11:46:27 UTC'), job.assigned
|
23
|
+
assert_equal Time.parse('2012-02-23 11:46:37 UTC'), job.preparing
|
24
|
+
assert_equal Time.parse('2012-02-23 11:46:41 UTC'), job.building
|
25
|
+
assert_equal Time.parse('2012-02-23 11:46:42 UTC'), job.completing
|
26
|
+
assert_equal Time.parse('2012-02-23 11:46:45 UTC'), job.completed
|
27
|
+
end
|
28
|
+
|
29
|
+
test "should parse job even when some properties are missing" do
|
30
|
+
stub_request(:get, "http://go-server.1.project:8153/go/api/jobs/1.xml").to_return(:body => file_contents("jobs_with_no_properties.xml"))
|
31
|
+
link = "http://go-server.1.project:8153/go/api/jobs/1.xml"
|
32
|
+
job = GoApiClient::Job.from(link)
|
33
|
+
|
34
|
+
assert_equal 80, job.duration
|
35
|
+
assert_equal "Failed", job.result
|
36
|
+
%w(scheduled assigned preparing building completing completed).each do |property|
|
37
|
+
assert_nil job.send(property)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
class PipelineTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
stub_request(:get, "http://localhost:8153/go/api/pipelines/defaultPipeline/1.xml").to_return(:body => file_contents("pipelines_1.xml"))
|
8
|
+
end
|
9
|
+
|
10
|
+
test "should fetch the pipeline xml and populate itself" do
|
11
|
+
link = "http://localhost:8153/go/api/pipelines/defaultPipeline/1.xml"
|
12
|
+
pipeline = GoApiClient::Pipeline.from(link)
|
13
|
+
|
14
|
+
assert_equal "1", pipeline.label
|
15
|
+
assert_equal 99, pipeline.counter
|
16
|
+
assert_equal "defaultPipeline", pipeline.name
|
17
|
+
assert_equal "http://localhost:8153/go/api/pipelines/defaultPipeline/1.xml", pipeline.url
|
18
|
+
assert_equal ["Update README", "Fixed build"], pipeline.commits.collect(&:message)
|
19
|
+
assert_equal "urn:x-go.studios.thoughtworks.com:job-id:defaultPipeline:1", pipeline.identifier
|
20
|
+
assert_equal Time.parse('2012-02-23 11:46:15 UTC'), pipeline.schedule_time
|
21
|
+
end
|
22
|
+
|
23
|
+
test "should return a list of authors from the first stage" do
|
24
|
+
link = "http://localhost:8153/go/api/pipelines/defaultPipeline/1.xml"
|
25
|
+
pipeline = GoApiClient::Pipeline.from(link)
|
26
|
+
author_foo = Atom::Author.new(nil, :name => 'foo', :email => 'foo@example.com', :uri => 'http://foo.example.com')
|
27
|
+
author_bar = Atom::Author.new(nil, :name => 'bar', :email => 'bar@example.com', :uri => 'http://bar.example.com')
|
28
|
+
|
29
|
+
pipeline.stages << OpenStruct.new(:authors => [author_foo, author_bar])
|
30
|
+
assert_equal [author_foo, author_bar], pipeline.authors
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
class StageTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
test "should return stages in order" do
|
7
|
+
stub_request(:any, /.*go-server.2.project.*/).
|
8
|
+
to_return(
|
9
|
+
lambda do |request|
|
10
|
+
{ :body => file_contents("ordering/#{request.uri.path}")}
|
11
|
+
end
|
12
|
+
).times(9999)
|
13
|
+
|
14
|
+
runs = GoApiClient.runs(:host => 'go-server.2.project')
|
15
|
+
|
16
|
+
assert_equal runs[:pipelines].collect(&:counter).sort, runs[:pipelines].collect(&:counter)
|
17
|
+
|
18
|
+
runs[:pipelines].each do |pipeline|
|
19
|
+
assert_equal pipeline.stages.collect(&:completed_at).sort, pipeline.stages.collect(&:completed_at)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
test "should parse stage" do
|
24
|
+
stub_request(:get, "http://localhost:8153/go/api/pipelines/defaultPipeline/1.xml").to_return(:body => file_contents("pipelines_1.xml"))
|
25
|
+
stub_request(:get, "http://localhost:8153/go/api/stages/1.xml").to_return(:body => file_contents("stages_1.xml"))
|
26
|
+
stub_request(:get, "http://localhost:8153/go/api/stages/2.xml").to_return(:body => file_contents("stages_2.xml"))
|
27
|
+
stub_request(:get, "http://localhost:8153/go/api/jobs/1.xml").to_return(:body => file_contents("jobs_1.xml"))
|
28
|
+
stub_request(:get, "http://localhost:8153/go/api/jobs/2.xml").to_return(:body => file_contents("jobs_2.xml"))
|
29
|
+
|
30
|
+
stub_request(:get, "http://localhost:8153/go/api/pipelines/defaultPipeline/stages.xml").to_return(:body => file_contents("stages.xml"))
|
31
|
+
runs = GoApiClient.runs(:host => "localhost", :port => 8153)
|
32
|
+
pipelines = runs[:pipelines]
|
33
|
+
assert_equal "http://localhost:8153/go/pipelines/defaultPipeline/1/Acceptance/1", runs[:latest_atom_entry_id]
|
34
|
+
stages = pipelines.first.stages
|
35
|
+
|
36
|
+
assert_equal 1, pipelines.count
|
37
|
+
assert_equal 2, stages.count
|
38
|
+
|
39
|
+
assert_equal "http://localhost:8153/go/api/stages/1.xml", stages.first.url
|
40
|
+
assert_equal "http://localhost:8153/go/api/stages/2.xml", stages.last.url
|
41
|
+
|
42
|
+
assert_equal 1, stages.first.counter
|
43
|
+
assert_equal 1, stages.last.counter
|
44
|
+
|
45
|
+
assert_equal [Time.parse("2012-02-23T17:16:41+05:30").utc, Time.parse("2012-02-23T17:19:31+05:30").utc], stages.collect(&:completed_at)
|
46
|
+
|
47
|
+
assert_equal [Atom::Author.new(nil, :name => 'oogabooga', :email => 'twgosaas@gmail.com')], pipelines.first.authors
|
48
|
+
|
49
|
+
stages.each do |stage|
|
50
|
+
assert_equal Atom::Author.new(nil, :name => 'oogabooga', :email => 'twgosaas@gmail.com'), stage.authors.first
|
51
|
+
assert_equal "Failed", stage.result
|
52
|
+
assert stage.failed?
|
53
|
+
assert false == stage.passed?
|
54
|
+
end
|
55
|
+
|
56
|
+
assert_equal "Units", stages.first.name
|
57
|
+
assert_equal "Acceptance", stages.last.name
|
58
|
+
|
59
|
+
assert_equal ["Update README", "Fixed build"], pipelines.first.commits.collect(&:message)
|
60
|
+
|
61
|
+
assert_equal "http://localhost:8153/go/files/defaultPipeline/1/Units/1/Test/cruise-output/console.log", stages.first.jobs.first.console_log_url
|
62
|
+
assert_equal "http://localhost:8153/go/files/defaultPipeline/1/Acceptance/1/Test/cruise-output/console.log", stages.last.jobs.first.console_log_url
|
63
|
+
|
64
|
+
assert_equal 'urn:x-go.studios.thoughtworks.com:stage-id:defaultPipeline:1:Units:1', stages.first.identifier
|
65
|
+
assert_equal 'urn:x-go.studios.thoughtworks.com:stage-id:defaultPipeline:1:Acceptance:1', stages.last.identifier
|
66
|
+
end
|
67
|
+
|
68
|
+
test "empty atom feed should not throw up" do
|
69
|
+
stub_request(:get, "http://localhost:8153/go/api/pipelines/defaultPipeline/stages.xml").to_return(:body => file_contents("stages_empty.xml"))
|
70
|
+
runs = GoApiClient.runs(:host => "localhost", :port => 8153)
|
71
|
+
|
72
|
+
assert runs[:pipelines].empty?
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|