Skip to content

Commit

Permalink
#10 tests for jmsqueue
Browse files Browse the repository at this point in the history
  • Loading branch information
Kozakowski Karol committed Jan 22, 2016
1 parent 35811dd commit ed5af80
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/puppet_x/coi/jboss/provider/jmsqueue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def exists?
def durable
trace 'durable'
Puppet.debug "Durable given: #{@resource[:durable].inspect}"
# normalization
$data['durable'].to_bool.to_s
end

Expand Down
59 changes: 58 additions & 1 deletion spec/unit/provider/jboss_jmsqueue/jbosscli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
it { expect(subject).to eq(true) }
end

describe '#exists?' do
describe '#exists? with result => true' do
before :each do
$data = nil
cmd = "/subsystem=messaging/hornetq-server=default/jms-queue=#{resource[:name]}:read-resource()"
Expand All @@ -144,5 +144,62 @@
subject { provider.exists? }
it { expect(subject).to eq(true) }
end

describe '#exists? with result => false' do
before :each do
$data = nil
cmd = "/subsystem=messaging/hornetq-server=default/jms-queue=#{resource[:name]}:read-resource()"
compiledCMD = "/profile=full-ha#{cmd}"

expected_output = {
:result => false,
:data => 'asd',
}

expect(provider).to receive(:compilecmd).with(cmd).and_return(compiledCMD)
expect(provider).to receive(:executeAndGet).with(compiledCMD).and_return(expected_output)
end

subject { provider.exists? }
it { expect(subject).to eq(false) }
end

describe '#durable' do
before :each do
$data = {
'durable' => 'true',
}
end
subject { provider.durable }
it { expect(subject).to eq("true") }
end

describe '#durable = true' do
before :each do
expect(provider).to receive(:setattr).with('durable', "\"true\"").and_return(true)
end
subject { provider.durable = "true" }
it { expect(subject).to eq("true") }
end

describe '#entries' do
before :each do
$data = {
'entries' => 'asd',
}
end
subject { provider.entries }
it { expect(subject).to eq('asd') }
end

describe "#entries with true" do
before :each do
entries = "[\"true\"]"
expect(provider).to receive(:setattr).with('entries', entries).and_return("true")
end

subject { provider.entries= ['true'] }
it { expect(subject).to eq (["true"]) }
end
end
end

0 comments on commit ed5af80

Please sign in to comment.