go_api_client 0.5.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.travis.yml +26 -0
- data/README.md +86 -0
- data/go_api_client.gemspec +11 -11
- data/lib/go_api_client/api/abstract_api.rb +12 -0
- data/lib/go_api_client/api/cctray.rb +53 -0
- data/lib/go_api_client/api/config.rb +60 -0
- data/lib/go_api_client/api/feed.rb +39 -0
- data/lib/go_api_client/api/job.rb +34 -0
- data/lib/go_api_client/api/pipeline.rb +87 -0
- data/lib/go_api_client/api/properties.rb +43 -0
- data/lib/go_api_client/api/stage.rb +45 -0
- data/lib/go_api_client/attribute_helper.rb +9 -0
- data/lib/go_api_client/client.rb +20 -0
- data/lib/go_api_client/domain/artifact.rb +16 -0
- data/lib/go_api_client/domain/author.rb +22 -0
- data/lib/go_api_client/domain/changeset.rb +13 -0
- data/lib/go_api_client/domain/config/job.rb +15 -0
- data/lib/go_api_client/domain/config/pipeline.rb +15 -0
- data/lib/go_api_client/domain/config/stage.rb +15 -0
- data/lib/go_api_client/domain/entry.rb +13 -0
- data/lib/go_api_client/domain/feed.rb +13 -0
- data/lib/go_api_client/domain/internal_cache.rb +28 -0
- data/lib/go_api_client/domain/job.rb +17 -0
- data/lib/go_api_client/domain/material.rb +14 -0
- data/lib/go_api_client/domain/pipeline.rb +27 -0
- data/lib/go_api_client/domain/project.rb +14 -0
- data/lib/go_api_client/domain/scheduled_job.rb +12 -0
- data/lib/go_api_client/domain/stage.rb +28 -0
- data/lib/go_api_client/domain/user.rb +30 -0
- data/lib/go_api_client/http_fetcher.rb +73 -48
- data/lib/go_api_client/parsers/artifact_parser.rb +17 -0
- data/lib/go_api_client/parsers/author_parser.rb +24 -0
- data/lib/go_api_client/parsers/changeset.rb +26 -0
- data/lib/go_api_client/parsers/config/job_parser.rb +48 -0
- data/lib/go_api_client/parsers/config/pipeline_parser.rb +42 -0
- data/lib/go_api_client/parsers/config/stage_parser.rb +33 -0
- data/lib/go_api_client/parsers/entry_parser.rb +27 -0
- data/lib/go_api_client/parsers/feed_parser.rb +27 -0
- data/lib/go_api_client/parsers/job_parser.rb +47 -0
- data/lib/go_api_client/parsers/material_parser.rb +29 -0
- data/lib/go_api_client/parsers/parser_helper.rb +11 -0
- data/lib/go_api_client/parsers/pipeline_parser.rb +30 -0
- data/lib/go_api_client/parsers/project_parser.rb +26 -0
- data/lib/go_api_client/parsers/scheduled_job_parser.rb +28 -0
- data/lib/go_api_client/parsers/stage_parser.rb +31 -0
- data/lib/go_api_client/parsers/user_parser.rb +12 -0
- data/lib/go_api_client/version.rb +4 -4
- data/lib/go_api_client.rb +56 -110
- data/test/go_api_client/artifact_test.rb +8 -8
- data/test/go_api_client/author_test.rb +27 -0
- data/test/go_api_client/building_test.rb +21 -19
- data/test/go_api_client/{atom/entry_test.rb → entry_test.rb} +8 -8
- data/test/go_api_client/job_test.rb +15 -14
- data/test/go_api_client/pipeline_test.rb +24 -27
- data/test/go_api_client/stage_test.rb +21 -74
- data/test/go_api_client/user_test.rb +15 -20
- metadata +108 -78
- data/.init.sh +0 -8
- data/.rbenv-gemsets +0 -1
- data/.ruby-version +0 -1
- data/.rvmrc +0 -1
- data/.yardopts +0 -6
- data/Gemfile.lock +0 -32
- data/README.textile +0 -64
- data/lib/go_api_client/artifact.rb +0 -27
- data/lib/go_api_client/atom/author.rb +0 -42
- data/lib/go_api_client/atom/entry.rb +0 -34
- data/lib/go_api_client/atom/feed.rb +0 -40
- data/lib/go_api_client/atom/feed_page.rb +0 -49
- data/lib/go_api_client/atom.rb +0 -4
- data/lib/go_api_client/commit.rb +0 -30
- data/lib/go_api_client/helpers/simple_attribute_support.rb +0 -11
- data/lib/go_api_client/helpers.rb +0 -1
- data/lib/go_api_client/job.rb +0 -68
- data/lib/go_api_client/pipeline.rb +0 -48
- data/lib/go_api_client/stage.rb +0 -57
- data/lib/go_api_client/user.rb +0 -36
- data/test/go_api_client/atom/author_test.rb +0 -27
- data/test/go_api_client/atom/feed_page_test.rb +0 -41
- data/test/go_api_client/atom/feed_test.rb +0 -39
- data/test/go_api_client/commit_test.rb +0 -38
- data/test/schedule_test.rb +0 -12
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
module Parsers
|
5
|
+
class Material
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def parse(root)
|
9
|
+
url = root.attributes['url'].value if root.attributes['url']
|
10
|
+
branch = root.attributes['url'].value if root.attributes['branch']
|
11
|
+
pipeline_name = root.attributes['pipelineName'].value if root.attributes['pipelineName']
|
12
|
+
stage_name = root.attributes['stageName'].value if root.attributes['stageName']
|
13
|
+
GoApiClient::Domain::Material.new(
|
14
|
+
{
|
15
|
+
:uri => root.attributes['materialUri'].value,
|
16
|
+
:type => root.attributes['type'].value,
|
17
|
+
:url => url,
|
18
|
+
:branch => branch,
|
19
|
+
:pipeline_name => pipeline_name,
|
20
|
+
:stage_name => stage_name,
|
21
|
+
:parsed_changesets => root.xpath('./modifications/changeset').collect do |element|
|
22
|
+
GoApiClient::Parsers::Changeset.parse(element)
|
23
|
+
end
|
24
|
+
})
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
module Parsers
|
5
|
+
class Pipeline < GoApiClient::Parsers::Helper
|
6
|
+
class << self
|
7
|
+
def parse(root)
|
8
|
+
GoApiClient::Domain::Pipeline.new(
|
9
|
+
{
|
10
|
+
:name => root.attributes['name'].value,
|
11
|
+
:label => root.attributes['label'].value,
|
12
|
+
:counter => root.attributes['counter'].value.to_i,
|
13
|
+
:self_uri => href_from(root.xpath("./link[@rel='self']")),
|
14
|
+
:inserted_after_uri => href_from(root.xpath("./link[@rel='insertedAfter']")),
|
15
|
+
:id => root.xpath('./id').first.content,
|
16
|
+
:schedule_time => Time.parse(root.xpath('./scheduleTime').first.content).utc,
|
17
|
+
:approved_by => root.xpath('./approvedBy').first.content,
|
18
|
+
:stages => root.xpath('./stages/stage').collect do |element|
|
19
|
+
element.attributes['href'].value
|
20
|
+
end,
|
21
|
+
:parsed_materials => root.xpath('./materials/material').collect do |element|
|
22
|
+
GoApiClient::Parsers::Material.parse(element)
|
23
|
+
end
|
24
|
+
})
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
module Parsers
|
5
|
+
class Project < GoApiClient::Parsers::Helper
|
6
|
+
class << self
|
7
|
+
def parse(root)
|
8
|
+
messages = root.xpath('./messages/message').collect do |element|
|
9
|
+
{:text => element.attributes['text'].value, :kind => element.attributes['kind'].value}
|
10
|
+
end if root.xpath('./messages/message')
|
11
|
+
GoApiClient::Domain::Project.new(
|
12
|
+
{
|
13
|
+
:name => root.attributes['name'].value,
|
14
|
+
:activity => root.attributes['activity'].value,
|
15
|
+
:last_build_status => root.attributes['lastBuildStatus'].value,
|
16
|
+
:last_build_label => root.attributes['lastBuildLabel'].value,
|
17
|
+
:last_build_time => Time.parse(root.attributes['lastBuildTime'].value).utc,
|
18
|
+
:web_uri => root.attributes['webUrl'].value,
|
19
|
+
:parsed_messages => messages
|
20
|
+
})
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module GoApiClient
|
2
|
+
module Parsers
|
3
|
+
class ScheduledJob < GoApiClient::Parsers::Helper
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def parse(root)
|
7
|
+
environment = root.xpath('./environment').first.content if root.xpath('./environment').first
|
8
|
+
resources = root.xpath('./resources/resource').collect do |element|
|
9
|
+
element.content
|
10
|
+
end if root.xpath('./resources/resource')
|
11
|
+
environment_variables = root.xpath('./environmentVariables/variable').collect do |element|
|
12
|
+
{:name => element.attributes['name'].value, :value => element.content}
|
13
|
+
end if root.xpath('./environmentVariables/variable')
|
14
|
+
GoApiClient::Domain::ScheduledJob.new(
|
15
|
+
{
|
16
|
+
:name => root.attributes['name'].value,
|
17
|
+
:id => root.attributes['id'].value.to_i,
|
18
|
+
:self_uri => href_from(root.xpath("./link[@rel='self']")),
|
19
|
+
:build_locator => root.xpath('./buildLocator').first.content,
|
20
|
+
:environment => environment,
|
21
|
+
:resources => resources,
|
22
|
+
:environment_variables => environment_variables
|
23
|
+
})
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
module Parsers
|
5
|
+
class Stage < GoApiClient::Parsers::Helper
|
6
|
+
class << self
|
7
|
+
def parse(root)
|
8
|
+
GoApiClient::Domain::Stage.new(
|
9
|
+
{
|
10
|
+
:name => root.attributes['name'].value,
|
11
|
+
:counter => root.attributes['counter'].value.to_i,
|
12
|
+
:id => root.xpath('./id').first.content,
|
13
|
+
:self_uri => href_from(root.xpath("./link[@rel='self']")),
|
14
|
+
:result => root.xpath('./result').first.content,
|
15
|
+
:updated => Time.parse(root.xpath('./updated').first.content).utc,
|
16
|
+
:state => root.xpath('./state').first.content,
|
17
|
+
:approved_by => root.xpath('./approvedBy').first.content,
|
18
|
+
:jobs => root.xpath('./jobs/job').collect do |element|
|
19
|
+
element.attributes['href'].value
|
20
|
+
end,
|
21
|
+
:pipeline_name => root.xpath('./pipeline').first.attributes['name'].value,
|
22
|
+
:pipeline_counter => root.xpath('./pipeline').first.attributes['counter'].value,
|
23
|
+
:pipeline_label => root.xpath('./pipeline').first.attributes['label'].value,
|
24
|
+
:pipeline_uri => root.xpath('./pipeline').first.attributes['href'].value
|
25
|
+
})
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
data/lib/go_api_client.rb
CHANGED
@@ -1,119 +1,65 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
require 'net/http'
|
4
|
-
|
5
|
-
require 'go_api_client/version'
|
6
|
-
require 'go_api_client/helpers'
|
7
|
-
require 'go_api_client/http_fetcher'
|
8
|
-
|
9
|
-
require 'go_api_client/atom'
|
10
|
-
require 'go_api_client/pipeline'
|
11
|
-
require 'go_api_client/stage'
|
12
|
-
require 'go_api_client/job'
|
13
|
-
require 'go_api_client/artifact'
|
14
|
-
require 'go_api_client/commit'
|
15
|
-
require 'go_api_client/user'
|
16
1
|
require 'go_api_client/logger'
|
17
|
-
require 'go_api_client/
|
2
|
+
require 'go_api_client/version'
|
18
3
|
|
19
4
|
module GoApiClient
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
5
|
+
autoload :Client, 'go_api_client/client'
|
6
|
+
autoload :HttpFetcher, 'go_api_client/http_fetcher'
|
7
|
+
autoload :Engine, 'go_api_client/engine' if defined?(::Rails)
|
8
|
+
autoload :AttributeHelper, 'go_api_client/attribute_helper'
|
9
|
+
|
10
|
+
module Api
|
11
|
+
autoload :AbstractApi, 'go_api_client/api/abstract_api'
|
12
|
+
autoload :Cctray, 'go_api_client/api/cctray'
|
13
|
+
autoload :Config, 'go_api_client/api/config'
|
14
|
+
autoload :Pipeline, 'go_api_client/api/pipeline'
|
15
|
+
autoload :Properties, 'go_api_client/api/properties'
|
16
|
+
autoload :Feed, 'go_api_client/api/feed'
|
17
|
+
autoload :Job, 'go_api_client/api/job'
|
18
|
+
autoload :Stage, 'go_api_client/api/stage'
|
35
19
|
end
|
36
20
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
pipeline_name = options[:pipeline_name] || "defaultPipeline"
|
58
|
-
feed_url = "#{options[:ssl] ? 'https' : 'http'}://#{options[:host]}:#{options[:port]}/go/api/pipelines/#{pipeline_name}/stages.xml"
|
59
|
-
feed = GoApiClient::Atom::Feed.new(feed_url, options[:latest_atom_entry_id])
|
60
|
-
feed.fetch!(http_fetcher)
|
61
|
-
return construct_last_run(feed, http_fetcher, options[:latest_atom_entry_id])
|
62
|
-
end
|
63
|
-
|
64
|
-
def all_runs(options={})
|
65
|
-
options = ({:ssl => false, :host => 'localhost', :port => 8153, :username => nil, :password => nil}).merge(options)
|
66
|
-
http_fetcher = GoApiClient::HttpFetcher.new(:username => options[:username], :password => options[:password])
|
67
|
-
feed_url = "#{options[:ssl] ? 'https' : 'http'}://#{options[:host]}:#{options[:port]}/go/api/pipelines.xml"
|
68
|
-
feed = GoApiClient::Atom::Feed.new(feed_url, nil)
|
69
|
-
feed = feed.fetch_all!(http_fetcher)
|
70
|
-
feed.inject({}) do |memo, (href, entries)|
|
71
|
-
memo[href] = construct_last_run(entries, http_fetcher, nil)
|
72
|
-
memo
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
# Answers if a build is in progress. For the list of supported connection options see {GoApiClient.runs #runs}
|
77
|
-
# @see .build_finished?
|
78
|
-
def build_in_progress?(options={})
|
79
|
-
raise ArgumentError("Hostname is mandatory") unless options[:host]
|
80
|
-
options = ({:ssl => false, :port => 8153, :username => nil, :password => nil, :pipeline_name => 'defaultPipeline'}).merge(options)
|
81
|
-
http_fetcher = GoApiClient::HttpFetcher.new(:username => options[:username], :password => options[:password])
|
82
|
-
url = "#{options[:ssl] ? 'https' : 'http'}://#{options[:host]}:#{options[:port]}/go/cctray.xml"
|
83
|
-
doc = Nokogiri::XML(http_fetcher.get!(url))
|
84
|
-
doc.css("Project[activity='Building'][name^='#{options[:pipeline_name]} ::']").count > 0
|
85
|
-
end
|
86
|
-
|
87
|
-
# Answers if a build is in completed. For the list of supported connection options see {GoApiClient.runs #runs}
|
88
|
-
# @see .build_in_progress?
|
89
|
-
def build_finished?(options)
|
90
|
-
!build_in_progress?(options)
|
91
|
-
end
|
92
|
-
|
93
|
-
# Schedule a particular pipeline with the latest available materials.
|
94
|
-
def schedule_pipeline(options)
|
95
|
-
raise ArgumentError("Hostname is mandatory") unless options[:host]
|
96
|
-
options = ({:ssl => false, :port => 8153, :username => nil, :password => nil, :pipeline_name => 'defaultPipeline'}).merge(options)
|
97
|
-
|
98
|
-
uri = "#{options[:ssl] ? 'https' : 'http'}://#{options[:host]}:#{options[:port]}/go/api/pipelines/#{options[:pipeline_name]}/schedule"
|
99
|
-
GoApiClient::HttpFetcher.new.post!(uri)
|
21
|
+
module Domain
|
22
|
+
autoload :Author, 'go_api_client/domain/author'
|
23
|
+
autoload :Artifact, 'go_api_client/domain/artifact'
|
24
|
+
autoload :Changeset, 'go_api_client/domain/changeset'
|
25
|
+
autoload :Entry, 'go_api_client/domain/entry'
|
26
|
+
autoload :Feed, 'go_api_client/domain/feed'
|
27
|
+
autoload :InternalCache, 'go_api_client/domain/internal_cache'
|
28
|
+
autoload :Job, 'go_api_client/domain/job'
|
29
|
+
autoload :ScheduledJob, 'go_api_client/domain/scheduled_job'
|
30
|
+
autoload :Pipeline, 'go_api_client/domain/pipeline'
|
31
|
+
autoload :Stage, 'go_api_client/domain/stage'
|
32
|
+
autoload :Material, 'go_api_client/domain/material'
|
33
|
+
autoload :Project, 'go_api_client/domain/project'
|
34
|
+
autoload :User, 'go_api_client/domain/user'
|
35
|
+
|
36
|
+
module Config
|
37
|
+
autoload :Pipeline, 'go_api_client/domain/config/pipeline'
|
38
|
+
autoload :Stage, 'go_api_client/domain/config/stage'
|
39
|
+
autoload :Job, 'go_api_client/domain/config/job'
|
100
40
|
end
|
41
|
+
end
|
101
42
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
43
|
+
module Parsers
|
44
|
+
autoload :Author, 'go_api_client/parsers/author_parser'
|
45
|
+
autoload :Artifact, 'go_api_client/parsers/artifact_parser'
|
46
|
+
autoload :Changeset, 'go_api_client/parsers/changeset'
|
47
|
+
autoload :Material, 'go_api_client/parsers/material_parser'
|
48
|
+
autoload :Job, 'go_api_client/parsers/job_parser'
|
49
|
+
autoload :ScheduledJob, 'go_api_client/parsers/scheduled_job_parser'
|
50
|
+
autoload :Helper, 'go_api_client/parsers/parser_helper'
|
51
|
+
autoload :Pipeline, 'go_api_client/parsers/pipeline_parser'
|
52
|
+
autoload :Stage, 'go_api_client/parsers/stage_parser'
|
53
|
+
autoload :Author, 'go_api_client/parsers/author_parser'
|
54
|
+
autoload :Entry, 'go_api_client/parsers/entry_parser'
|
55
|
+
autoload :Feed, 'go_api_client/parsers/feed_parser'
|
56
|
+
autoload :Project, 'go_api_client/parsers/project_parser'
|
57
|
+
autoload :User, 'go_api_client/parsers/user_parser'
|
58
|
+
|
59
|
+
module Config
|
60
|
+
autoload :Pipeline, 'go_api_client/parsers/config/pipeline_parser'
|
61
|
+
autoload :Stage, 'go_api_client/parsers/config/stage_parser'
|
62
|
+
autoload :Job, 'go_api_client/parsers/config/job_parser'
|
117
63
|
end
|
118
64
|
end
|
119
|
-
end
|
65
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
module GoApiClient
|
4
4
|
class ArtifactTest < Test::Unit::TestCase
|
5
|
-
test
|
6
|
-
|
5
|
+
test 'should construct the artifacts from the job xml' do
|
6
|
+
link = 'http://localhost:8153/go/api/jobs/3.xml'
|
7
|
+
stub_request(:get, link).to_return(:body => file_contents('jobs_3.xml'))
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
assert_equal
|
11
|
-
assert_equal
|
12
|
-
assert_equal "https://ci.snap-ci.com/go/files/Go-SaaS-Rails/898/Dist/1/rpm/log.zip", job.artifacts.last.as_zip_file_url
|
9
|
+
job = GoApiClient::Client.new.api(:job).job({:job_uri => link})
|
10
|
+
assert_equal 2, job.parsed_artifacts.count
|
11
|
+
assert_equal 'https://ci.snap-ci.com/go/files/Go-SaaS-Rails/898/Dist/1/rpm/tmp.zip', job.parsed_artifacts.first.as_zip_file_url
|
12
|
+
assert_equal 'https://ci.snap-ci.com/go/files/Go-SaaS-Rails/898/Dist/1/rpm/log.zip', job.parsed_artifacts.last.as_zip_file_url
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -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('<author xmlns="http://www.w3.org/2005/Atom"><name><![CDATA[oogabooga <twgosaas@gmail.com>]]></name><uri>http://oogabooga.example.com<uri></author>')
|
9
|
+
author = GoApiClient::Parsers::Author.parse(doc.root)
|
10
|
+
assert_equal GoApiClient::Domain::Author.new({: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('<author xmlns="http://www.w3.org/2005/Atom"><name><![CDATA[oogabooga]]></name></author>')
|
15
|
+
author = GoApiClient::Parsers::Author.parse(doc.root)
|
16
|
+
assert_equal GoApiClient::Domain::Author.new({: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('<author xmlns="http://www.w3.org/2005/Atom"><name><![CDATA[oogabooga <twgosaas@gmail.com>]]></name></author>')
|
21
|
+
author = GoApiClient::Parsers::Author.parse(doc.root)
|
22
|
+
assert_equal GoApiClient::Domain::Author.new({:name => 'oogabooga', :email => 'twgosaas@gmail.com'}), author
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
module GoApiClient
|
4
4
|
class BuildingTest < Test::Unit::TestCase
|
5
5
|
|
6
|
-
test
|
7
|
-
feed =
|
6
|
+
test 'should report that Go is building if atleast 1 stage in specified pipeline is building' do
|
7
|
+
feed = '
|
8
8
|
<?xml version="1.0" encoding="utf-8"?>
|
9
9
|
<Projects>
|
10
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" />
|
@@ -13,15 +13,16 @@ module GoApiClient
|
|
13
13
|
<Project name="anotherPipeline :: 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" />
|
14
14
|
<Project name="anotherPipeline :: SmokeTests" 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" />
|
15
15
|
</Projects>
|
16
|
-
|
17
|
-
stub_request(:get,
|
18
|
-
|
19
|
-
|
20
|
-
assert_false
|
16
|
+
'
|
17
|
+
stub_request(:get, 'http://go-server.2.project:8153/go/cctray.xml').to_return(:body => feed)
|
18
|
+
|
19
|
+
cctray_api = GoApiClient::Client.new({:host => 'go-server.2.project'}).api(:cctray)
|
20
|
+
assert_false cctray_api.projects({:pipeline_name => 'defaultPipeline', :activity => 'Building'}).empty?
|
21
|
+
assert cctray_api.projects({:pipeline_name => 'anotherPipeline', :activity => 'Building'}).empty?
|
21
22
|
end
|
22
23
|
|
23
|
-
test
|
24
|
-
feed =
|
24
|
+
test 'should report that Go is sleeping if all stages in specified pipeline are sleeping' do
|
25
|
+
feed = '
|
25
26
|
<?xml version="1.0" encoding="utf-8"?>
|
26
27
|
<Projects>
|
27
28
|
<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" />
|
@@ -30,17 +31,18 @@ module GoApiClient
|
|
30
31
|
<Project name="anotherPipeline :: 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" />
|
31
32
|
<Project name="anotherPipeline :: SmokeTests" 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" />
|
32
33
|
</Projects>
|
33
|
-
|
34
|
-
stub_request(:get,
|
35
|
-
|
36
|
-
|
37
|
-
assert_false
|
34
|
+
'
|
35
|
+
stub_request(:get, 'http://go-server.2.project:8153/go/cctray.xml').to_return(:body => feed)
|
36
|
+
|
37
|
+
cctray_api = GoApiClient::Client.new({:host => 'go-server.2.project'}).api(:cctray)
|
38
|
+
assert_false cctray_api.projects({:pipeline_name => 'anotherPipeline', :activity => 'Building'}).empty?
|
39
|
+
assert cctray_api.projects({:pipeline_name => 'defaultPipeline', :activity => 'Building'}).empty?
|
38
40
|
end
|
39
41
|
|
40
|
-
test
|
41
|
-
stub_request(:get,
|
42
|
-
|
43
|
-
|
42
|
+
test 'should handle empty feeds' do
|
43
|
+
stub_request(:get, 'http://go-server.2.project:8153/go/cctray.xml').to_return(:body => nil)
|
44
|
+
cctray_api = GoApiClient::Client.new({:host => 'go-server.2.project'}).api(:cctray)
|
45
|
+
assert cctray_api.projects({:pipeline_name => 'defaultPipeline', :activity => 'Building'}).empty?
|
44
46
|
end
|
45
47
|
|
46
48
|
end
|