summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-03-11 22:18:59 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-03-11 22:18:59 +0000
commitfa9aab6749bcb76004b567e228c5af8f7a4bfee8 (patch)
tree15aa928fd00bcdec80ccb88642f93139e794d9d5 /test
parent414d364a6f337cc8e542dc107d8e51f625375db4 (diff)
Fixing #82. You can now specify comma-separated tags to get run in puppet or puppetd: puppetd --onetime --tags "enhost, facter" -v. You cannot specify classes explicitly, but tags map well to classes and have the benefit of being more generic.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1005 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rw-r--r--test/tagging/tagging.rb68
1 files changed, 67 insertions, 1 deletions
diff --git a/test/tagging/tagging.rb b/test/tagging/tagging.rb
index ed3bd9fbb..3f1f15add 100644
--- a/test/tagging/tagging.rb
+++ b/test/tagging/tagging.rb
@@ -71,10 +71,76 @@ class TestTagging < Test::Unit::TestCase
object = objects.shift
assert_nothing_raised {
- assert_equal(%w{solaris}, object.tags,
+ assert_equal([:solaris], object.tags,
"Incorrect tags")
}
end
+
+ # Make sure that specifying tags results in only those objects getting
+ # run.
+ def test_tagspecs
+ a = tempfile()
+ b = tempfile()
+
+ afile = Puppet.type(:file).create(
+ :path => a,
+ :ensure => :file
+ )
+ afile.tag("a")
+
+ bfile = Puppet.type(:file).create(
+ :path => b,
+ :ensure => :file
+ )
+ bfile.tag(:b)
+
+ # First, make sure they get created when no spec'ed tags
+ assert_events([:file_created,:file_created], afile, bfile)
+ assert(FileTest.exists?(a), "A did not get created")
+ assert(FileTest.exists?(b), "B did not get created")
+ File.unlink(a)
+ File.unlink(b)
+
+ # Set the tags to a
+ assert_nothing_raised {
+ Puppet[:tags] = "a"
+ }
+
+ assert_events([:file_created], afile, bfile)
+ assert(FileTest.exists?(a), "A did not get created")
+ assert(!FileTest.exists?(b), "B got created")
+ File.unlink(a)
+
+ # Set the tags to b
+ assert_nothing_raised {
+ Puppet[:tags] = "b"
+ }
+
+ assert_events([:file_created], afile, bfile)
+ assert(!FileTest.exists?(a), "A got created")
+ assert(FileTest.exists?(b), "B did not get created")
+ File.unlink(b)
+
+ # Set the tags to something else
+ assert_nothing_raised {
+ Puppet[:tags] = "c"
+ }
+
+ assert_events([], afile, bfile)
+ assert(!FileTest.exists?(a), "A got created")
+ assert(!FileTest.exists?(b), "B got created")
+
+ # Now set both tags
+ assert_nothing_raised {
+ Puppet[:tags] = "b, a"
+ }
+
+ assert_events([:file_created, :file_created], afile, bfile)
+ assert(FileTest.exists?(a), "A did not get created")
+ assert(FileTest.exists?(b), "B did not get created")
+ File.unlink(a)
+
+ end
end
# $Id$