Skip to content

Commit

Permalink
Revert "Upgrade to fleet-api 1.0.0"
Browse files Browse the repository at this point in the history
This reverts commit fcd02a3.
  • Loading branch information
alexwelch committed Feb 25, 2015
1 parent 8a0595d commit 1a5f14f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ gem 'puma', '2.8.2'
gem 'sqlite3', '1.3.9'
gem 'faraday_middleware', '0.9.0'
gem 'docker-api', '1.13.0', require: 'docker'
gem 'fleet-api', '1.1.0', require: 'fleet'
gem 'fleet-api', '0.6.0', require: 'fleet'
gem 'active_model_serializers', '0.9.0'
gem 'octokit', '3.2.0'
gem 'kmts', '2.0.1'
Expand Down
7 changes: 4 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ GEM
multipart-post (~> 1.2.0)
faraday_middleware (0.9.0)
faraday (>= 0.7.4, < 0.9)
fleet-api (1.1.0)
excon (>= 0.27.4)
fleet-api (0.6.0)
faraday (= 0.8.9)
faraday_middleware (= 0.9.0)
hike (1.2.3)
i18n (0.7.0)
its (0.2.0)
Expand Down Expand Up @@ -151,7 +152,7 @@ DEPENDENCIES
database_cleaner (= 1.3.0)
docker-api (= 1.13.0)
faraday_middleware (= 0.9.0)
fleet-api (= 1.1.0)
fleet-api (= 0.6.0)
its
kmts (= 2.0.1)
octokit (= 3.2.0)
Expand Down
7 changes: 1 addition & 6 deletions app/services/service_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,7 @@ def destroy
end

def get_state
states = fleet_client.get_unit_state(@service.unit_name)
{
load_state: states['systemdLoadState'],
active_state: states['systemdActiveState'],
sub_state: states['systemdSubState']
}
fleet_client.status(@service.unit_name)
rescue
{}
end
Expand Down
14 changes: 5 additions & 9 deletions spec/services/service_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,30 +183,26 @@
describe '#get_state' do

let(:fleet_state) do
{
'systemdLoadState' => 'a',
'systemdActiveState' => 'b',
'systemdSubState' => 'c'
}
{ load: 'loaded', run: 'running' }
end

before do
allow(fake_fleet_client).to receive(:get_unit_state).and_return(fleet_state)
allow(fake_fleet_client).to receive(:status).and_return(fleet_state)
end

it 'retrieves service state from the fleet client' do
expect(fake_fleet_client).to receive(:get_unit_state).with(service.unit_name)
expect(fake_fleet_client).to receive(:status).with(service.unit_name)
subject.get_state
end

it 'returns the states' do
expect(subject.get_state).to eq(load_state: 'a', active_state: 'b', sub_state: 'c')
expect(subject.get_state).to eq(load: 'loaded', run: 'running')
end

context 'when an error occurs while querying fleet' do

before do
allow(fake_fleet_client).to receive(:get_unit_state).and_raise('boom')
allow(fake_fleet_client).to receive(:status).and_raise('boom')
end

it 'returns an empty hash' do
Expand Down

0 comments on commit 1a5f14f

Please sign in to comment.