Skip to content
This repository has been archived by the owner on Jun 19, 2020. It is now read-only.

Commit

Permalink
(FACT-2183) Add Solaris's uptime legacy facts
Browse files Browse the repository at this point in the history
  • Loading branch information
Oana Tanasoiu committed May 13, 2020
1 parent 0962fc1 commit b99dab7
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 12 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/acceptance_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,9 @@ jobs:
sudo chmod a-w /home/runner /usr/share &&
sudo chmod -R a-w /usr/share/rust /home/runner/.config /home/linuxbrew
- name: Instal dhclient
if: runner.os == 'Linux'
run: sudo apt install dhcpcd5

- name: Run acceptance tests
run: sudo -E "PATH=$PATH" ruby facter_4/.github/actions/presuite.rb
3 changes: 2 additions & 1 deletion lib/facts/solaris/system_uptime/days.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ module Solaris
module SystemUptime
class Days
FACT_NAME = 'system_uptime.days'
ALIASES = 'uptime_days'

def call_the_resolver
fact_value = Facter::Resolvers::Uptime.resolve(:days)

Facter::ResolvedFact.new(FACT_NAME, fact_value)
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/facts/solaris/system_uptime/hours.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ module Solaris
module SystemUptime
class Hours
FACT_NAME = 'system_uptime.hours'
ALIASES = 'uptime_hours'

def call_the_resolver
fact_value = Facter::Resolvers::Uptime.resolve(:hours)

Facter::ResolvedFact.new(FACT_NAME, fact_value)
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/facts/solaris/system_uptime/seconds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ module Solaris
module SystemUptime
class Seconds
FACT_NAME = 'system_uptime.seconds'
ALIASES = 'uptime_seconds'

def call_the_resolver
fact_value = Facter::Resolvers::Uptime.resolve(:seconds)

Facter::ResolvedFact.new(FACT_NAME, fact_value)
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/facts/solaris/system_uptime/uptime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ module Solaris
module SystemUptime
class Uptime
FACT_NAME = 'system_uptime.uptime'
ALIASES = 'uptime'

def call_the_resolver
fact_value = Facter::Resolvers::Uptime.resolve(:uptime)

Facter::ResolvedFact.new(FACT_NAME, fact_value)
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions spec/facter/facts/solaris/system_uptime/days_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
end

it 'returns days since last boot' do
expect(fact.call_the_resolver).to be_an_instance_of(Facter::ResolvedFact).and \
have_attributes(name: 'system_uptime.days', value: value)
expect(fact.call_the_resolver).to be_an_instance_of(Array).and \
contain_exactly(an_object_having_attributes(name: 'system_uptime.days', value: value),
an_object_having_attributes(name: 'uptime_days', value: value, type: :legacy))
end
end
end
5 changes: 3 additions & 2 deletions spec/facter/facts/solaris/system_uptime/hours_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
end

it 'returns hours since last boot' do
expect(fact.call_the_resolver).to be_an_instance_of(Facter::ResolvedFact).and \
have_attributes(name: 'system_uptime.hours', value: value)
expect(fact.call_the_resolver).to be_an_instance_of(Array).and \
contain_exactly(an_object_having_attributes(name: 'system_uptime.hours', value: value),
an_object_having_attributes(name: 'uptime_hours', value: value, type: :legacy))
end
end
end
5 changes: 3 additions & 2 deletions spec/facter/facts/solaris/system_uptime/seconds_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
end

it 'returns minutes since last boot' do
expect(fact.call_the_resolver).to be_an_instance_of(Facter::ResolvedFact).and \
have_attributes(name: 'system_uptime.seconds', value: value)
expect(fact.call_the_resolver).to be_an_instance_of(Array).and \
contain_exactly(an_object_having_attributes(name: 'system_uptime.seconds', value: value),
an_object_having_attributes(name: 'uptime_seconds', value: value, type: :legacy))
end
end
end
5 changes: 3 additions & 2 deletions spec/facter/facts/solaris/system_uptime/uptime_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
end

it 'returns total uptime since last boot' do
expect(fact.call_the_resolver).to be_an_instance_of(Facter::ResolvedFact).and \
have_attributes(name: 'system_uptime.uptime', value: value)
expect(fact.call_the_resolver).to be_an_instance_of(Array).and \
contain_exactly(an_object_having_attributes(name: 'system_uptime.uptime', value: value),
an_object_having_attributes(name: 'uptime', value: value, type: :legacy))
end
end
end

0 comments on commit b99dab7

Please sign in to comment.