Comments (8)
Please try specifying the facter version you want to test through setting facterversion
on on_supported_os
(see https://github.com/mcanevet/rspec-puppet-facts/blob/fe21de12108fbab0123bdc4db2365a29ea62f171/lib/rspec-puppet-facts.rb#L34) . This could use a sentence or two in the README to make it discoverable.
Related, there is talk on getting cfacter (that is, facter 3) into gems for testing: https://tickets.puppetlabs.com/browse/FACT-1542 . please vote there to help prioritise this issue.
from rspec-puppet-facts.
@DavidS any good way to get this in the spec_helper.rb so I don't have to specify in the array of the spec test?
from rspec-puppet-facts.
@DavidS tried the following but didn't work (you can see the commented out stubbed fact I had to use before):
on_supported_os({
supported_os: [
{
'operatingsystem' => 'CentOS',
'operatingsystemrelease' => [
'7'
],
'facterversion' => '3.6.4'
}
]
}).each do |os, facts|
context "on #{os}" do
let(:facts) do
facts.merge({
puppetversion: Puppet.version,
sudoversion: '1.7.10p9',
ap_env: 'dev',
role: 'mapi',
awsregion: 'us-east-1'
# memory: {
# system: {
# total_bytes: '1111'
# }
# }
})
end
Even tried:
on_supported_os({
supported_os: [
{
'operatingsystem' => 'CentOS',
'operatingsystemrelease' => [
'7'
]
}
]
}).each do |os, facts|
context "on #{os}" do
let(:facts) do
facts.merge({
facterversion: '3.6.4',
puppetversion: Puppet.version,
sudoversion: '1.7.10p9',
ap_env: 'dev',
role: 'mapi',
awsregion: 'us-east-1'
# memory: {
# system: {
# total_bytes: '1111'
# }
# }
})
end
from rspec-puppet-facts.
I even tried to move this to spec_helper.rb with no luck:
RSpec.configure do |c|
c.tty = true
c.mock_framework = :rspec
c.mock_with(:rspec)
c.after(:suite) do
RSpec::Puppet::Coverage.report!(95)
end
c.hiera_config = File.expand_path(
File.join(__FILE__, '../fixtures/hiera.yaml')
)
default_facts = {
puppetversion: Puppet.version,
facterversion: '3.6.4'
}
c.default_facts = default_facts
end
But oddly if I do this in my own script it will return just fine ( facterversion > 2.5.1 ):
require 'facterdb'
require 'rspec-puppet-facts'
facterversion = ARGV[0]
facter_version_filter = RspecPuppetFacts.facter_version_to_filter(facterversion)
db = FacterDB.get_facts({ :facterversion => facter_version_filter })
version = facterversion
filter = []
filter << {
:facterversion => facter_version_filter,
:operatingsystem => 'CentOS',
:operatingsystemmajrelease => '7',
:hardwaremodel => 'x86_64',
}
received_facts = FacterDB::get_facts(filter)
puts received_facts[0].to_h[:memory]['system']['total_bytes']
gitlab/test-puppet - [modulesync-a4c2046a●] » be ruby mytest.rb 3.6.1
512798720
gitlab/test-puppet - [modulesync-a4c2046a●] » be ruby mytest.rb 3.7
6089424896
gitlab/test-puppet - [modulesync-a4c2046a●] » be ruby mytest.rb 3.4
6089424896
gitlab/test-puppet - [modulesync-a4c2046a●] » be ruby mytest.rb 3.0
514228224
gitlab/test-puppet - [modulesync-a4c2046a●] » be ruby mytest.rb 2.5
mytest.rb:21:in `<main>': undefined method `[]' for nil:NilClass (NoMethodError)
from rspec-puppet-facts.
I found a way to do it within the individual spec ... the facterversion
has to be on the same level as supported_os
:
on_supported_os({
facterversion: '3.7',
supported_os: [
{
'operatingsystem' => 'CentOS',
'operatingsystemrelease' => [
'7'
]
}
]
}).each do |os, facts|
context "on #{os}" do
let(:facts) do
facts.merge({
puppetversion: Puppet.version,
sudoversion: '1.7.10p9',
ap_env: 'dev',
role: 'mapi',
awsregion: 'us-east-1'
# memory: {
# system: {
# total_bytes: '1111'
# }
# }
})
end
Does anyone know how to get that to work from the spec_helper.rb example above... doesn't appear to be reading default_facts
.
from rspec-puppet-facts.
Any update on this, fighting with the same issue.
from rspec-puppet-facts.
Ugly as it is the way I worked around this in my spec_helper file was to do something like this
require 'facter'
module Facter
def self.version
ENV['FACTER_VERSION'] || '3.8.0'
end
end
from rspec-puppet-facts.
Facter 2.5.1 appears to be working. If someone would like to send a patch to allow for cfacter, I would be happy to add it to the test matrix.
from rspec-puppet-facts.
Related Issues (20)
- rspec-puppet-facts hangs searching for facter version HOT 3
- More docs changes needed HOT 1
- Overriding structured facts HOT 3
- Memoizing facts HOT 3
- remove json as a dependency HOT 2
- Cut a new release HOT 1
- Reduce calls to FacterDB
- Allow modules to export custom fact values HOT 1
- Push 2.0.1 git tag to Github HOT 1
- Fail tests when no facts are found in facterdb
- "add_custom_fact" creates String-Facts instead of Symbol-Facts HOT 1
- release notes for 3.0.0
- Cut a new release to support windows server 2016 HOT 5
- facterversion filter fails with windows and facter version 3.x HOT 2
- File resource is trying to load Windows provider on a non-Windows computer HOT 2
- AIX hardware model should not be x86_64 HOT 2
- PR #72 breaks Puppet 6 HOT 5
- Specify required_ruby_version
- facts cannot be cased as described HOT 7
- Commit 21442e7 looks to introduce hard to debug behavior HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rspec-puppet-facts.