Skip to content

Commit

Permalink
fix: rename file according to test content
Browse files Browse the repository at this point in the history
  • Loading branch information
shieldwed committed Oct 5, 2023
1 parent 762d3a2 commit d69dc18
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 56 deletions.
56 changes: 15 additions & 41 deletions spec/puppet-lint/plugins/check_global_function_spec.rb
Original file line number Diff line number Diff line change
@@ -1,59 +1,33 @@
require "spec_helper"

describe "global_resource" do
context "just a class" do
let(:code) { "class test { file { 'file': } }" }

it "should not detect any problems" do
expect(problems).to have(0).problems
end
end

context "just a define" do
let(:code) { "define test ($param = undef) { file { 'file': } }" }

it "should not detect any problems" do
expect(problems).to have(0).problems
describe "global_function" do
context "just a function" do
let(:code) do
<<-EOS
class test {
ensure_packages(['wordpress']);
}
EOS
end
end

context "allow node resources" do
let(:code) { "node 'test' { file { 'file': } }" }

it "should not detect any problems" do
expect(problems).to have(0).problems
end
end

context "global file" do
let(:code) do
"file { 'file': } define test ($param = undef) { file { 'file': } }"
end

it "should detect a problem" do
expect(problems).to have(1).problems
end
end

context "global includes" do
let(:code) { "class test { file { 'file': } } \ninclude testclass" }

it "should detect a problem" do
expect(problems).to have(1).problems
end
end

context "global defaults" do
context "global functions" do
let(:code) do
<<-EOS
Exec {
path => '/usr/bin:/usr/sbin/:/bin:/sbin',
class test {
ensure_packages(['wordpress']);
}
ensure_packages(['wordpress']);
EOS
end

it "should not detect any problems" do
expect(problems).to have(0).problems
it "should detect a problem" do
expect(problems).to have(1).problems
end
end
end
56 changes: 41 additions & 15 deletions spec/puppet-lint/plugins/check_global_resource_spec.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,59 @@
require "spec_helper"

describe "global_function" do
context "just a function" do
let(:code) do
<<-EOS
class test {
ensure_packages(['wordpress']);
}
EOS
describe "global_resource" do
context "just a class" do
let(:code) { "class test { file { 'file': } }" }

it "should not detect any problems" do
expect(problems).to have(0).problems
end
end

context "just a define" do
let(:code) { "define test ($param = undef) { file { 'file': } }" }

it "should not detect any problems" do
expect(problems).to have(0).problems
end
end

context "global functions" do
context "allow node resources" do
let(:code) { "node 'test' { file { 'file': } }" }

it "should not detect any problems" do
expect(problems).to have(0).problems
end
end

context "global file" do
let(:code) do
<<-EOS
class test {
ensure_packages(['wordpress']);
}
"file { 'file': } define test ($param = undef) { file { 'file': } }"
end

ensure_packages(['wordpress']);
EOS
it "should detect a problem" do
expect(problems).to have(1).problems
end
end

context "global includes" do
let(:code) { "class test { file { 'file': } } \ninclude testclass" }

it "should detect a problem" do
expect(problems).to have(1).problems
end
end

context "global defaults" do
let(:code) do
<<-EOS
Exec {
path => '/usr/bin:/usr/sbin/:/bin:/sbin',
}
EOS
end

it "should not detect any problems" do
expect(problems).to have(0).problems
end
end
end

0 comments on commit d69dc18

Please sign in to comment.