summaryrefslogtreecommitdiffstats
path: root/test/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-10-17 21:38:30 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-10-17 21:38:30 +0000
commit95f2fe70bf63791fb691d539281f5cfbfd1fb664 (patch)
treebde480ce5ada8ea2abbc5fecf8f5c9aa3ca2aabf /test/lib
parent86dae84dad4cd5688029c398109b15b6074cf3c4 (diff)
downloadpuppet-95f2fe70bf63791fb691d539281f5cfbfd1fb664.tar.gz
puppet-95f2fe70bf63791fb691d539281f5cfbfd1fb664.tar.xz
puppet-95f2fe70bf63791fb691d539281f5cfbfd1fb664.zip
Ported mount over to using providers
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1801 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/lib')
-rw-r--r--test/lib/puppettest/fakes.rb30
-rw-r--r--test/lib/puppettest/support/utils.rb13
2 files changed, 40 insertions, 3 deletions
diff --git a/test/lib/puppettest/fakes.rb b/test/lib/puppettest/fakes.rb
index f2d424295..40fe96a10 100644
--- a/test/lib/puppettest/fakes.rb
+++ b/test/lib/puppettest/fakes.rb
@@ -3,6 +3,7 @@ require 'puppettest'
module PuppetTest
# A baseclass for the faketypes.
class FakeModel
+ include Puppet::Util
class << self
attr_accessor :name
@name = :fakemodel
@@ -29,7 +30,8 @@ module PuppetTest
end
def []=(param, value)
- unless @realmodel.attrtype(param)
+ param = symbolize(param)
+ unless @realmodel.validattr?(param)
raise Puppet::DevError, "Invalid attribute %s for %s" %
[param, @realmodel.name]
end
@@ -46,7 +48,7 @@ module PuppetTest
@is = {}
@should = {}
@params = {}
- self[:name] = name
+ self[@realmodel.namevar] = name
end
def inspect
@@ -121,6 +123,29 @@ module PuppetTest
end
end
+ class FakeParsedProvider < FakeProvider
+ def hash
+ ret = {}
+ instance_variables.each do |v|
+ v = v.sub("@", '')
+ if val = self.send(v)
+ ret[v.intern] = val
+ end
+ end
+
+ return ret
+ end
+
+ def store(hash)
+ hash.each do |n, v|
+ method = n.to_s + "="
+ if respond_to? method
+ send(method, v)
+ end
+ end
+ end
+ end
+
@@fakemodels = {}
@@fakeproviders = {}
@@ -132,7 +157,6 @@ module PuppetTest
end
obj = @@fakemodels[type].new(name)
- obj[:name] = name
options.each do |name, val|
obj[name] = val
end
diff --git a/test/lib/puppettest/support/utils.rb b/test/lib/puppettest/support/utils.rb
index ea2d5483c..c7d54d5e6 100644
--- a/test/lib/puppettest/support/utils.rb
+++ b/test/lib/puppettest/support/utils.rb
@@ -142,6 +142,19 @@ module PuppetTest
return comp
end
+
+ def setme
+ # retrieve the user name
+ id = %x{id}.chomp
+ if id =~ /uid=\d+\(([^\)]+)\)/
+ @me = $1
+ else
+ puts id
+ end
+ unless defined? @me
+ raise "Could not retrieve user name; 'id' did not work"
+ end
+ end
end
# $Id$