-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from coi-gov-pl/feature/1-even-more-tests-befo…
…re-release Enh #1 Even more tests before release
- Loading branch information
Showing
9 changed files
with
280 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
guard 'rake', :task => :spec_ruby do | ||
watch(%r{spec/(unit|functions|hosts|integration|types)/.+_spec\.rb}) | ||
watch(%r{lib/.+\.rb}) | ||
end | ||
guard 'rake', :task => :spec_puppet_prepared do | ||
watch(%r{spec/(classes|defines)/.+_spec\.rb}) | ||
watch(%r{manifests/.+\.pp}) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'spec_helper' | ||
|
||
describe 'jboss_running', :type => :fact do | ||
subject { Facter.value(:jboss_running) } | ||
it { expect { subject }.not_to raise_error } | ||
it { expect(subject).to match('^(?:true|false)$') } | ||
end |
25 changes: 25 additions & 0 deletions
25
spec/unit/lib/provider/datasource/post_wildfly_provider_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'spec_helper' | ||
require 'puppet_x/coi/jboss/provider/datasource/post_wildfly_provider' | ||
|
||
describe Puppet_X::Coi::Jboss::Provider::Datasource::PostWildFlyProvider do | ||
|
||
let(:xa) { false } | ||
let(:jta) { true } | ||
let(:provider) { double("Provider") } | ||
before do | ||
allow(provider).to receive(:xa?).and_return(xa) | ||
allow(provider).to receive(:getattrib).and_return(jta) | ||
end | ||
let(:target) { described_class.new(provider) } | ||
|
||
describe 'xa_datasource_properties_wrapper' do | ||
let(:parameters) { 'david=one,martha=tree' } | ||
subject { target.xa_datasource_properties_wrapper(parameters) } | ||
it { expect(subject).to eq('{david=one,martha=tree}') } | ||
end | ||
|
||
describe 'jta' do | ||
subject { target.jta } | ||
it { expect(subject).to eq('true') } | ||
end | ||
end |
13 changes: 13 additions & 0 deletions
13
spec/unit/lib/provider/datasource/pre_wildfly_provider_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'spec_helper' | ||
require 'puppet_x/coi/jboss/provider/datasource/pre_wildfly_provider' | ||
|
||
describe Puppet_X::Coi::Jboss::Provider::Datasource::PreWildFlyProvider do | ||
|
||
let(:target) { described_class.new(nil) } | ||
|
||
describe 'xa_datasource_properties_wrapper' do | ||
let(:parameters) { 'david=one,martha=tree' } | ||
subject { target.xa_datasource_properties_wrapper(parameters) } | ||
it { expect(subject).to eq('[david=one,martha=tree]') } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
require 'spec_helper' | ||
|
||
describe 'jboss_datasource', :type => :type do | ||
let(:described_class) { Puppet::Type.type(:jboss_datasource) } | ||
subject { described_class } | ||
it { expect(subject).not_to be_nil } | ||
let(:ex_class) { if Puppet.version > '3.0.0' then Puppet::ResourceError else Puppet::Error end } | ||
|
||
def extend_params(given) | ||
{ | ||
:title => 'spec-datasource' | ||
}.merge(given) | ||
end | ||
|
||
let(:type) { described_class.new(params) } | ||
|
||
describe 'controller' do | ||
context 'given :undef' do | ||
let(:params) { extend_params({ :controller => :undef }) } | ||
it do | ||
expect { type }.to raise_error(ex_class, | ||
'Parameter controller failed on Jboss_datasource[spec-datasource]: Domain controller must be provided') | ||
end | ||
end | ||
end | ||
|
||
describe 'port' do | ||
context 'given invalid text' do | ||
let(:params) { extend_params({ :port => "an invalid port" }) } | ||
it do | ||
expect { type }.to raise_error(ex_class, | ||
'Parameter port failed on Jboss_datasource[spec-datasource]: Datasource port is invalid, given "an invalid port"') | ||
end | ||
end | ||
context 'given "5x45"' do | ||
let(:params) { extend_params({ :port => "5x45" }) } | ||
before { skip('FIXME: A buggy host validation, ref: coi-gov-pl/puppet-jboss#8') } | ||
it do | ||
expect { type }.to raise_error(ex_class, | ||
'Parameter port failed on Jboss_datasource[spec-datasource]: Datasource port is invalid, given "an invalid port"') | ||
end | ||
end | ||
context 'property :port' do | ||
subject { type.property :port } | ||
context 'given as "7778"' do | ||
let(:params) { extend_params({ :port => "7778" }) } | ||
its(:value) { should == 7778 } | ||
end | ||
context 'given as ""' do | ||
let(:params) { extend_params({ :port => "" }) } | ||
its(:value) { should == 0 } | ||
end | ||
end | ||
end | ||
|
||
describe 'host' do | ||
context 'given invalid text " "' do | ||
let(:params) { extend_params({ :host => ' ' }) } | ||
it do | ||
expect { type }.to raise_error(ex_class, | ||
'Parameter host failed on Jboss_datasource[spec-datasource]: Datasource host is invalid, given " "') | ||
end | ||
end | ||
context 'given "an invalid host"' do | ||
before { skip('FIXME: A buggy host validation, ref: coi-gov-pl/puppet-jboss#8') } | ||
let(:params) { extend_params({ :host => "an invalid host" }) } | ||
it do | ||
expect { type }.to raise_error(ex_class, | ||
'Parameter host failed on Jboss_datasource[spec-datasource]: Datasource host is invalid, given "an invalid host"') | ||
end | ||
end | ||
end | ||
|
||
describe 'minpoolsize' do | ||
subject { type.property :minpoolsize } | ||
context 'given invalid text' do | ||
let(:params) { extend_params({ :minpoolsize => "an invalid text" }) } | ||
its(:value) { should == 1 } | ||
end | ||
context 'given 13.45' do | ||
let(:params) { extend_params({ :minpoolsize => 13.45 }) } | ||
its(:value) { should == 13 } | ||
end | ||
context 'given :undef' do | ||
let(:params) { extend_params({ :minpoolsize => :undef }) } | ||
its(:value) { should == 1 } | ||
end | ||
context 'given "17"' do | ||
let(:params) { extend_params({ :minpoolsize => '17' }) } | ||
its(:value) { should == 17 } | ||
end | ||
end | ||
|
||
describe 'maxpoolsize' do | ||
subject { type.property :maxpoolsize } | ||
context 'given invalid text' do | ||
let(:params) { extend_params({ :maxpoolsize => "an invalid text" }) } | ||
its(:value) { should == 50 } | ||
end | ||
context 'given 13.45' do | ||
let(:params) { extend_params({ :maxpoolsize => 13.45 }) } | ||
its(:value) { should == 13 } | ||
end | ||
context 'given :undef' do | ||
let(:params) { extend_params({ :maxpoolsize => :undef }) } | ||
its(:value) { should == 50 } | ||
end | ||
context 'given "17"' do | ||
let(:params) { extend_params({ :maxpoolsize => '17' }) } | ||
its(:value) { should == 17 } | ||
end | ||
end | ||
|
||
describe 'password' do | ||
let(:params) { extend_params({ :password => "an invalid text" }) } | ||
let(:expected_message) { 'password has been changed.' } | ||
subject { type.property(:password).change_to_s(from, to) } | ||
context 'change_to_s' do | ||
context ':absent, "test-passwd"' do | ||
let(:from) { :absent } | ||
let(:to) { 'test-passwd' } | ||
it { expect(subject).to eq(expected_message) } | ||
end | ||
context '"test-passwd", :absent' do | ||
let(:from) { 'test-passwd' } | ||
let(:to) { :absent } | ||
it { expect(subject).to eq(expected_message) } | ||
end | ||
end | ||
end | ||
|
||
describe 'options' do | ||
let(:params) do | ||
extend_params({ | ||
:options => options | ||
}) | ||
end | ||
context 'given invalid text' do | ||
before { skip('FIXME: String should not be accepted as a parameter, ref: coi-gov-pl/puppet-jboss#9')} | ||
let(:options) { "an invalid text" } | ||
it do | ||
expect { type }.to raise_error(ex_class, | ||
'Parameter options failed on Jboss_datasource[spec-datasource]: You can pass only hash-like objects') | ||
end | ||
end | ||
context 'given invalid boolean' do | ||
let(:options) { true } | ||
it do | ||
expect { type }.to raise_error(ex_class, | ||
'Parameter options failed on Jboss_datasource[spec-datasource]: You can pass only hash-like objects') | ||
end | ||
end | ||
context 'given' do | ||
let(:options) { {} } | ||
subject { type.property(:options).change_to_s(from, to) } | ||
context 'from :absent and to hash', :from => :absent, :to => { 'alice' => 'five', 'bob' => 'seven' } do | ||
before do | ||
msg = 'FIXME: Handle :symbols as parameters in change_to_s, ref: coi-gov-pl/puppet-jboss#9' | ||
skip(msg) if RUBY_VERSION < '1.9.0' | ||
end | ||
let(:from) { |expl| expl.metadata[:from] } | ||
let(:to) { |expl| expl.metadata[:to] } | ||
it { expect(subject).to eq("option 'alice' has changed from nil to \"five\", option 'bob' has changed from nil to \"seven\"") } | ||
end | ||
context 'from hash and to changed hash', :from => { 'alice' => 'five', 'bob' => 'nine' }, :to => { 'alice' => 'five', 'bob' => 'seven' } do | ||
let(:from) { |expl| expl.metadata[:from] } | ||
let(:to) { |expl| expl.metadata[:to] } | ||
it { expect(subject).to eq("option 'bob' has changed from \"nine\" to \"seven\"") } | ||
end | ||
context 'from hash and to :absent', :from => { 'alice' => 'five', 'bob' => 'nine' }, :to => :absent do | ||
before { skip('FIXME: A proper message while executing change_to_s for :to == :absent, ref: coi-gov-pl/puppet-jboss#9')} | ||
let(:from) { |expl| expl.metadata[:from] } | ||
let(:to) { |expl| expl.metadata[:to] } | ||
it { expect(subject).to eq('options has been removed') } | ||
end | ||
end | ||
end | ||
|
||
end |
1 change: 0 additions & 1 deletion
1
spec/unit/types/jdbcdriver_spec.rb → spec/unit/types/jboss_jdbcdriver_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters