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

(FACT-2183) Add Solaris's uptime legacy facts #511

Merged
merged 1 commit into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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