Deprecating the Puppet::Type.create.

This method is no longer necessary; you can use the
normal 'new' class method.

Signed-off-by: Luke Kanies <luke@madstop.com>
This commit is contained in:
Luke Kanies 2008-12-17 18:29:58 -06:00
Родитель b6db545851
Коммит e4ba3db196
78 изменённых файлов: 465 добавлений и 463 удалений

Просмотреть файл

@ -320,7 +320,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
hash[:ignore] = args[:ignore].split(/\s+/)
end
downconfig = Puppet::Resource::Catalog.new("downloading")
downconfig.add_resource Puppet::Type.type(:file).create(hash)
downconfig.add_resource Puppet::Type.type(:file).new(hash)
Puppet.info "Retrieving #{args[:name]}s"

Просмотреть файл

@ -512,7 +512,7 @@ class Puppet::Network::Handler
# the effort.
obj[:check] = CHECKPARAMS
else
obj = Puppet::Type.type(:file).create(
obj = Puppet::Type.type(:file).new(
:name => file_path(path, client),
:check => CHECKPARAMS
)

Просмотреть файл

@ -99,9 +99,9 @@ class Puppet::Resource
# instances for resource types that don't exist.
def to_ral
if typeklass = Puppet::Type.type(self.type)
return typeklass.create(self)
return typeklass.new(self)
else
return Puppet::Type::Component.create(self)
return Puppet::Type::Component.new(self)
end
end

Просмотреть файл

@ -181,7 +181,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
unless klass = Puppet::Type.type(type)
raise ArgumentError, "Unknown resource type %s" % type
end
return unless resource = klass.create(options)
return unless resource = klass.new(options)
add_resource(resource)
resource

Просмотреть файл

@ -953,6 +953,8 @@ class Type
# Force users to call this, so that we can merge objects if
# necessary.
def self.create(args)
# LAK:DEP Deprecation notice added 12/17/2008
Puppet.warning "Puppet::Type.create is deprecated; use Puppet::Type.new"
new(args)
end

Просмотреть файл

@ -268,7 +268,7 @@ module Puppet
obj[:check] = :all
files << obj
else
files << self.create(
files << self.new(
:name => path, :check => :all
)
end
@ -482,7 +482,7 @@ module Puppet
options.delete(param) if options.include?(param)
end
return self.class.create(options)
return self.class.new(options)
end
# Files handle paths specially, because they just lengthen their

Просмотреть файл

@ -56,7 +56,7 @@ module Puppet
# Create a default filebucket.
def self.mkdefaultbucket
self.create(:name => "puppet", :path => Puppet[:clientbucketdir])
new(:name => "puppet", :path => Puppet[:clientbucketdir])
end
def self.instances

Просмотреть файл

@ -46,7 +46,7 @@ module Puppet
if atype[name]
nil
else
malias = Puppet::Type.type(:mailalias).create(:name => name, :recipient => recipient, :ensure => should)
malias = Puppet::Type.type(:mailalias).new(:name => name, :recipient => recipient, :ensure => should)
end
end.compact
end

Просмотреть файл

@ -318,7 +318,7 @@ module Puppet
def self.mkdefaultschedules
result = []
Puppet.debug "Creating default schedules"
result << self.create(
result << self.new(
:name => "puppet",
:period => :hourly,
:repeat => "2"
@ -326,7 +326,7 @@ module Puppet
# And then one for every period
@parameters.find { |p| p.name == :period }.value_collection.values.each { |value|
result << self.create(
result << self.new(
:name => value.to_s,
:period => value
)

Просмотреть файл

@ -210,7 +210,7 @@ Puppet::Type.newtype(:tidy) do
# Make a file resource to remove a given file.
def mkfile(path)
# Force deletion, so directories actually get deleted.
Puppet::Type.type(:file).create :path => path, :backup => self[:backup], :ensure => :absent, :force => true
Puppet::Type.type(:file).new :path => path, :backup => self[:backup], :ensure => :absent, :force => true
end
def retrieve

Просмотреть файл

@ -18,7 +18,7 @@ require 'erb'
# def generate
# template = Puppet::Util::ResourceTemplate.new("/path/to/template", self)
#
# return Puppet::Type.type(:file).create :path => "/my/file",
# return Puppet::Type.type(:file).new :path => "/my/file",
# :content => template.evaluate
# end
#

Просмотреть файл

@ -35,7 +35,7 @@ describe Puppet::Type.type(:file) do
it "should be able to recurse over a nonexistent file" do
@path = tmpfile("file_integration_tests")
@file = Puppet::Type::File.create(:name => @path, :mode => 0644, :recurse => true)
@file = Puppet::Type::File.new(:name => @path, :mode => 0644, :recurse => true)
@catalog = Puppet::Resource::Catalog.new
@catalog.add_resource @file
@ -48,7 +48,7 @@ describe Puppet::Type.type(:file) do
build_path(@path)
@file = Puppet::Type::File.create(:name => @path, :mode => 0644, :recurse => true)
@file = Puppet::Type::File.new(:name => @path, :mode => 0644, :recurse => true)
@catalog = Puppet::Resource::Catalog.new
@catalog.add_resource @file
@ -71,7 +71,7 @@ describe Puppet::Type.type(:file) do
dest = tmpfile("file_link_integration_dest")
@file = Puppet::Type::File.create(:name => dest, :target => source, :recurse => true, :ensure => :link)
@file = Puppet::Type::File.new(:name => dest, :target => source, :recurse => true, :ensure => :link)
@catalog = Puppet::Resource::Catalog.new
@catalog.add_resource @file
@ -98,7 +98,7 @@ describe Puppet::Type.type(:file) do
dest = tmpfile("file_source_integration_dest")
@file = Puppet::Type::File.create(:name => dest, :source => source, :recurse => true)
@file = Puppet::Type::File.new(:name => dest, :source => source, :recurse => true)
@catalog = Puppet::Resource::Catalog.new
@catalog.add_resource @file
@ -133,7 +133,7 @@ describe Puppet::Type.type(:file) do
File.open(s1, "w") { |f| f.puts "uno" }
File.open(s2, "w") { |f| f.puts "dos" }
@file = Puppet::Type::File.create(:name => @dest, :source => @source, :recurse => true)
@file = Puppet::Type::File.new(:name => @dest, :source => @source, :recurse => true)
@catalog = Puppet::Resource::Catalog.new
@catalog.add_resource @file
@ -166,7 +166,7 @@ describe Puppet::Type.type(:file) do
File.open(source, "w") { |f| f.print "foo" }
file = Puppet::Type::File.create(:name => dest, :source => source)
file = Puppet::Type::File.new(:name => dest, :source => source)
catalog = Puppet::Resource::Catalog.new
catalog.add_resource file
@ -183,7 +183,7 @@ describe Puppet::Type.type(:file) do
File.open(source, "w") { |f| f.print "foo" }
file = Puppet::Type::File.create(:path => dest, :source => source)
file = Puppet::Type::File.new(:path => dest, :source => source)
catalog = Puppet::Resource::Catalog.new
catalog.add_resource file
@ -199,7 +199,7 @@ describe Puppet::Type.type(:file) do
File.open(source, "w") { |f| f.print "foo" }
file = Puppet::Type::File.create(:name => dest, :source => source)
file = Puppet::Type::File.new(:name => dest, :source => source)
catalog = Puppet::Resource::Catalog.new
catalog.add_resource file
@ -221,7 +221,7 @@ describe Puppet::Type.type(:file) do
File.open(source, "w") { |f| f.print "foo" }
file = Puppet::Type::File.create(:name => dest, :source => source, :recurse => true)
file = Puppet::Type::File.new(:name => dest, :source => source, :recurse => true)
catalog = Puppet::Resource::Catalog.new
catalog.add_resource file
@ -234,7 +234,7 @@ describe Puppet::Type.type(:file) do
it "should be able to create files when 'content' is specified but 'ensure' is not" do
dest = tmpfile("files_with_content")
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:name => dest,
:content => "this is some content, yo"
)
@ -249,7 +249,7 @@ describe Puppet::Type.type(:file) do
it "should create files with content if both 'content' and 'ensure' are set" do
dest = tmpfile("files_with_content")
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:name => dest,
:ensure => "file",
:content => "this is some content, yo"
@ -268,7 +268,7 @@ describe Puppet::Type.type(:file) do
File.open(source, "w") { |f| f.puts "yay" }
File.open(dest, "w") { |f| f.puts "boo" }
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:name => dest,
:ensure => :absent,
:source => source

Просмотреть файл

@ -17,7 +17,7 @@ describe Puppet::Type.type(:tidy) do
Dir.mkdir(dir)
File.symlink(target, link)
tidy = Puppet::Type.type(:tidy).create :path => dir, :recurse => true
tidy = Puppet::Type.type(:tidy).new :path => dir, :recurse => true
catalog = Puppet::Resource::Catalog.new
catalog.add_resource(tidy)

Просмотреть файл

@ -7,7 +7,7 @@ require 'puppet/type/selmodule'
describe Puppet::Type.type(:file), " when manipulating file contexts" do
before :each do
@file = Puppet::Type::File.create(
@file = Puppet::Type::File.new(
:name => "/tmp/foo",
:ensure => "file",
:seluser => "user_u",
@ -30,7 +30,7 @@ describe Puppet::Type.type(:selboolean), " when manipulating booleans" do
provider_class = Puppet::Type::Selboolean.provider(Puppet::Type::Selboolean.providers[0])
Puppet::Type::Selboolean.expects(:defaultprovider).returns provider_class
@bool = Puppet::Type::Selboolean.create(
@bool = Puppet::Type::Selboolean.new(
:name => "foo",
:value => "on",
:persistent => true )
@ -59,7 +59,7 @@ describe Puppet::Type.type(:selmodule), " when checking policy modules" do
provider_class = Puppet::Type::Selmodule.provider(Puppet::Type::Selmodule.providers[0])
Puppet::Type::Selmodule.expects(:defaultprovider).returns provider_class
@module = Puppet::Type::Selmodule.create(
@module = Puppet::Type::Selmodule.new(
:name => "foo",
:selmoduledir => "/some/path",
:selmodulepath => "/some/path/foo.pp",

Просмотреть файл

@ -88,25 +88,25 @@ describe Puppet::TransObject, " when converting to a RAL component instance" do
end
it "should use a new TransObject whose name is a resource reference of the type and title of the original TransObject" do
Puppet::Type::Component.expects(:create).with { |resource| resource.type == "component" and resource.name == "One::Two[/my/file]" }.returns(:yay)
Puppet::Type::Component.expects(:new).with { |resource| resource.type == "component" and resource.name == "One::Two[/my/file]" }.returns(:yay)
@resource.to_component.should == :yay
end
it "should pass the resource parameters on to the newly created TransObject" do
Puppet::Type::Component.expects(:create).with { |resource| resource["noop"] == "other" }.returns(:yay)
Puppet::Type::Component.expects(:new).with { |resource| resource["noop"] == "other" }.returns(:yay)
@resource.to_component.should == :yay
end
it "should copy over the catalog" do
@resource.catalog = "mycat"
Puppet::Type::Component.expects(:create).with { |resource| resource.catalog == "mycat" }.returns(:yay)
Puppet::Type::Component.expects(:new).with { |resource| resource.catalog == "mycat" }.returns(:yay)
@resource.to_component
end
# LAK:FIXME This really isn't the design we want going forward, but it's
# good enough for now.
it "should not pass resource parameters that are not metaparams" do
Puppet::Type::Component.expects(:create).with { |resource| resource["one"].nil? }.returns(:yay)
Puppet::Type::Component.expects(:new).with { |resource| resource["one"].nil? }.returns(:yay)
@resource.to_component.should == :yay
end
end

Просмотреть файл

@ -247,8 +247,8 @@ describe Puppet::Parser::Compiler do
end
it "should fail to add resources that conflict with existing resources" do
file1 = Puppet::Type.type(:file).create :path => "/foo"
file2 = Puppet::Type.type(:file).create :path => "/foo"
file1 = Puppet::Type.type(:file).new :path => "/foo"
file2 = Puppet::Type.type(:file).new :path => "/foo"
@compiler.add_resource(@scope, file1)
lambda { @compiler.add_resource(@scope, file2) }.should raise_error(Puppet::Resource::Catalog::DuplicateResourceError)

Просмотреть файл

@ -150,7 +150,7 @@ describe provider_class do
include ParsedMountTesting
before do
@mount = @mount_class.create :name => "/"
@mount = @mount_class.new :name => "/"
@provider = @mount.provider
end

Просмотреть файл

@ -214,14 +214,14 @@ describe Puppet::Resource do
it "should use the resource type's :create method to create the resource if the resource is of a builtin type" do
type = mock 'resource type'
type.expects(:create).with(@resource).returns(:myresource)
type.expects(:new).with(@resource).returns(:myresource)
Puppet::Type.expects(:type).with(@resource.type).returns(type)
@resource.to_ral.should == :myresource
end
it "should convert to a component instance if the resource type is not of a builtin type" do
component = mock 'component type'
Puppet::Type::Component.expects(:create).with(@resource).returns "meh"
Puppet::Type::Component.expects(:new).with(@resource).returns "meh"
Puppet::Type.expects(:type).with(@resource.type).returns(nil)
@resource.to_ral.should == "meh"

Просмотреть файл

@ -278,9 +278,9 @@ describe Puppet::Resource::Catalog, "when compiling" do
describe "when functioning as a resource container" do
before do
@catalog = Puppet::Resource::Catalog.new("host")
@one = Puppet::Type.type(:notify).create :name => "one"
@two = Puppet::Type.type(:notify).create :name => "two"
@dupe = Puppet::Type.type(:notify).create :name => "one"
@one = Puppet::Type.type(:notify).new :name => "one"
@two = Puppet::Type.type(:notify).new :name => "two"
@dupe = Puppet::Type.type(:notify).new :name => "one"
end
it "should provide a method to add one or more resources" do
@ -449,7 +449,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
end
it "should create aliases for resources isomorphic resources whose names do not match their titles" do
resource = Puppet::Type::File.create(:title => "testing", :path => "/something")
resource = Puppet::Type::File.new(:title => "testing", :path => "/something")
@catalog.add_resource(resource)
@ -457,7 +457,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
end
it "should not create aliases for resources non-isomorphic resources whose names do not match their titles" do
resource = Puppet::Type.type(:exec).create(:title => "testing", :command => "echo", :path => %w{/bin /usr/bin /usr/local/bin})
resource = Puppet::Type.type(:exec).new(:title => "testing", :command => "echo", :path => %w{/bin /usr/bin /usr/local/bin})
@catalog.add_resource(resource)
@ -507,7 +507,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
end
it "should add an alias for the namevar when the title and name differ on isomorphic resource types" do
resource = Puppet::Type.type(:file).create :path => "/something", :title => "other", :content => "blah"
resource = Puppet::Type.type(:file).new :path => "/something", :title => "other", :content => "blah"
resource.expects(:isomorphic?).returns(true)
@catalog.add_resource(resource)
@catalog.resource(:file, "other").should equal(resource)
@ -515,7 +515,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
end
it "should not add an alias for the namevar when the title and name differ on non-isomorphic resource types" do
resource = Puppet::Type.type(:file).create :path => "/something", :title => "other", :content => "blah"
resource = Puppet::Type.type(:file).new :path => "/something", :title => "other", :content => "blah"
resource.expects(:isomorphic?).returns(false)
@catalog.add_resource(resource)
@catalog.resource(:file, resource.title).should equal(resource)
@ -528,7 +528,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
it "should provide a method to create additional resources that also registers the resource" do
args = {:name => "/yay", :ensure => :file}
resource = stub 'file', :ref => "File[/yay]", :catalog= => @catalog, :title => "/yay", :[] => "/yay"
Puppet::Type.type(:file).expects(:create).with(args).returns(resource)
Puppet::Type.type(:file).expects(:new).with(args).returns(resource)
@catalog.create_resource :file, args
@catalog.resource("File[/yay]").should equal(resource)
end
@ -596,7 +596,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
@transaction.stubs(:evaluate)
@transaction.stubs(:cleanup)
@transaction.stubs(:addtimes)
Puppet::Type.type(:file).expects(:create).with(args).returns(resource)
Puppet::Type.type(:file).expects(:new).with(args).returns(resource)
resource.expects :remove
@catalog.apply do |trans|
@catalog.create_resource :file, args
@ -611,7 +611,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
@transaction.stubs(:evaluate)
@transaction.stubs(:cleanup)
@transaction.stubs(:addtimes)
file = Puppet::Type.type(:file).create(:name => "/yay", :ensure => :file)
file = Puppet::Type.type(:file).new(:name => "/yay", :ensure => :file)
@catalog.apply do |trans|
@catalog.add_resource file
@catalog.resource("File[/yay]").should_not be_nil
@ -690,18 +690,18 @@ describe Puppet::Resource::Catalog, "when compiling" do
before do
Puppet::Type.type(:component)
@catalog = Puppet::Resource::Catalog.new("host")
@compone = Puppet::Type::Component.create :name => "one"
@comptwo = Puppet::Type::Component.create :name => "two", :require => "Class[one]"
@compone = Puppet::Type::Component.new :name => "one"
@comptwo = Puppet::Type::Component.new :name => "two", :require => "Class[one]"
@file = Puppet::Type.type(:file)
@one = @file.create :path => "/one"
@two = @file.create :path => "/two"
@sub = @file.create :path => "/two/subdir"
@one = @file.new :path => "/one"
@two = @file.new :path => "/two"
@sub = @file.new :path => "/two/subdir"
@catalog.add_edge @compone, @one
@catalog.add_edge @comptwo, @two
@three = @file.create :path => "/three"
@four = @file.create :path => "/four", :require => "File[/three]"
@five = @file.create :path => "/five"
@three = @file.new :path => "/three"
@four = @file.new :path => "/four", :require => "File[/three]"
@five = @file.new :path => "/five"
@catalog.add_resource @compone, @comptwo, @one, @two, @three, @four, @five, @sub
@relationships = @catalog.relationship_graph

Просмотреть файл

@ -7,7 +7,7 @@ require 'puppet/transaction'
describe Puppet::Transaction do
before do
@generator_class = mkgenerator
@generator = mkgenerator.create(:name => "foo")
@generator = mkgenerator.new(:name => "foo")
@catalog = Puppet::Resource::Catalog.new
@catalog.add_resource @generator
@ -30,8 +30,8 @@ describe Puppet::Transaction do
end
it "should add all generated resources to the catalog" do
one = @generator_class.create :name => "one"
two = @generator_class.create :name => "two"
one = @generator_class.new :name => "one"
two = @generator_class.new :name => "two"
@generator.expects(:generate).returns [one, two]
@transaction.generate
@ -40,8 +40,8 @@ describe Puppet::Transaction do
end
it "should generate and add resources from the generated resources" do
one = @generator_class.create :name => "one"
two = @generator_class.create :name => "two"
one = @generator_class.new :name => "one"
two = @generator_class.new :name => "two"
@generator.expects(:generate).returns [one]
one.expects(:generate).returns [two]
@transaction.generate
@ -50,8 +50,8 @@ describe Puppet::Transaction do
end
it "should add an edge in the relationship graph between the generating and generated resource" do
one = @generator_class.create :name => "one"
two = @generator_class.create :name => "two"
one = @generator_class.new :name => "one"
two = @generator_class.new :name => "two"
@generator.expects(:generate).returns [one]
one.expects(:generate).returns [two]
@transaction.generate
@ -61,7 +61,7 @@ describe Puppet::Transaction do
end
it "should finish all non-conflicting resources" do
one = @generator_class.create :name => "one"
one = @generator_class.new :name => "one"
one.expects(:finish)
@generator.expects(:generate).returns [one]
@transaction.generate
@ -74,8 +74,8 @@ describe Puppet::Transaction do
end
it "should add all generated resources to the catalog" do
one = @generator_class.create :name => "one"
two = @generator_class.create :name => "two"
one = @generator_class.new :name => "one"
two = @generator_class.new :name => "two"
@generator.expects(:eval_generate).returns [one, two]
@transaction.eval_generate(@generator)
@ -84,7 +84,7 @@ describe Puppet::Transaction do
end
it "should add an edge in the relationship graph between the generating and generated resource" do
one = @generator_class.create :name => "one"
one = @generator_class.new :name => "one"
@generator.expects(:eval_generate).returns [one]
@transaction.eval_generate(@generator)
@ -92,15 +92,15 @@ describe Puppet::Transaction do
end
it "should not recursively eval_generate resources" do
one = @generator_class.create :name => "one"
two = @generator_class.create :name => "two"
one = @generator_class.new :name => "one"
two = @generator_class.new :name => "two"
@generator.expects(:eval_generate).returns [one]
one.expects(:eval_generate).never
@transaction.eval_generate(@generator)
end
it "should finish all non-conflicting resources" do
one = @generator_class.create :name => "one"
one = @generator_class.new :name => "one"
one.expects(:finish)
@generator.expects(:eval_generate).returns [one]
@transaction.eval_generate(@generator)

Просмотреть файл

@ -9,37 +9,37 @@ describe Puppet::Type do
it "should use its catalog as its expirer" do
catalog = Puppet::Resource::Catalog.new
resource = Puppet::Type.type(:mount).create(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
resource.catalog = catalog
resource.expirer.should equal(catalog)
end
it "should do nothing when asked to expire when it has no catalog" do
resource = Puppet::Type.type(:mount).create(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
lambda { resource.expire }.should_not raise_error
end
it "should be able to retrieve a property by name" do
resource = Puppet::Type.type(:mount).create(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
resource.property(:fstype).must be_instance_of(Puppet::Type.type(:mount).attrclass(:fstype))
end
it "should be able to retrieve a parameter by name" do
resource = Puppet::Type.type(:mount).create(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
resource.parameter(:name).must be_instance_of(Puppet::Type.type(:mount).attrclass(:name))
end
it "should be able to retrieve a property by name using the :parameter method" do
resource = Puppet::Type.type(:mount).create(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
resource.parameter(:fstype).must be_instance_of(Puppet::Type.type(:mount).attrclass(:fstype))
end
it "should have a method for setting default values for resources" do
Puppet::Type.type(:mount).create(:name => "foo").should respond_to(:set_default)
Puppet::Type.type(:mount).new(:name => "foo").should respond_to(:set_default)
end
it "should do nothing for attributes that have no defaults and no specified value" do
Puppet::Type.type(:mount).create(:name => "foo").parameter(:noop).should be_nil
Puppet::Type.type(:mount).new(:name => "foo").parameter(:noop).should be_nil
end
describe "when initializing" do
@ -247,7 +247,7 @@ describe Puppet::Type do
describe "when retrieving current property values" do
# Use 'mount' as an example, because it doesn't override 'retrieve'
before do
@resource = Puppet::Type.type(:mount).create(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
@resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
@properties = {}
end
@ -278,9 +278,9 @@ describe Puppet::Type do
describe "when in a catalog" do
before do
@catalog = Puppet::Resource::Catalog.new
@container = Puppet::Type.type(:component).create(:name => "container")
@one = Puppet::Type.type(:file).create(:path => "/file/one")
@two = Puppet::Type.type(:file).create(:path => "/file/two")
@container = Puppet::Type.type(:component).new(:name => "container")
@one = Puppet::Type.type(:file).new(:path => "/file/one")
@two = Puppet::Type.type(:file).new(:path => "/file/two")
@catalog.add_resource @container
@catalog.add_resource @one
@ -317,7 +317,7 @@ describe Puppet::Type::RelationshipMetaparam do
describe "when munging relationships" do
before do
@resource = Puppet::Type.type(:mount).create :name => "/foo"
@resource = Puppet::Type.type(:mount).new :name => "/foo"
@metaparam = Puppet::Type.metaparamclass(:require).new :resource => @resource
end

Просмотреть файл

@ -13,7 +13,7 @@ describe augeas do
end
it "should have a valid provider" do
augeas.create(:name => "foo").provider.class.ancestors.should be_include(Puppet::Provider)
augeas.new(:name => "foo").provider.class.ancestors.should be_include(Puppet::Provider)
end
end
@ -21,7 +21,7 @@ describe augeas do
it "should be able to create a instance" do
provider_class = Puppet::Type::Augeas.provider(Puppet::Type::Augeas.providers[0])
Puppet::Type::Augeas.expects(:defaultprovider).returns provider_class
augeas.create(:name => "bar").should_not be_nil
augeas.new(:name => "bar").should_not be_nil
end
it "should have an parse_commands feature" do
@ -67,23 +67,23 @@ describe augeas do
end
it "should be blank for context" do
augeas.create(:name => :context)[:context].should == ""
augeas.new(:name => :context)[:context].should == ""
end
it "should be blank for onlyif" do
augeas.create(:name => :onlyif)[:onlyif].should == ""
augeas.new(:name => :onlyif)[:onlyif].should == ""
end
it "should be blank for load_path" do
augeas.create(:name => :load_path)[:load_path].should == ""
augeas.new(:name => :load_path)[:load_path].should == ""
end
it "should be / for root" do
augeas.create(:name => :root)[:root].should == "/"
augeas.new(:name => :root)[:root].should == "/"
end
it "should be false for type_check" do
augeas.create(:name => :type_check)[:type_check].should == :false
augeas.new(:name => :type_check)[:type_check].should == :false
end
end

Просмотреть файл

@ -8,7 +8,7 @@ describe Puppet::Type.type(:computer), " when checking computer objects" do
before do
provider_class = Puppet::Type::Computer.provider(Puppet::Type::Computer.providers[0])
Puppet::Type::Computer.expects(:defaultprovider).returns provider_class
@resource = Puppet::Type::Computer.create(
@resource = Puppet::Type::Computer.new(
:name => "puppetcomputertest",
:en_address => "aa:bb:cc:dd:ee:ff",
:ip_address => "1.2.3.4")
@ -19,7 +19,7 @@ describe Puppet::Type.type(:computer), " when checking computer objects" do
it "should be able to create a instance" do
provider_class = Puppet::Type::Computer.provider(Puppet::Type::Computer.providers[0])
Puppet::Type::Computer.expects(:defaultprovider).returns provider_class
computer.create(:name => "bar").should_not be_nil
computer.new(:name => "bar").should_not be_nil
end
properties = [:en_address, :ip_address]
@ -58,11 +58,11 @@ describe Puppet::Type.type(:computer), " when checking computer objects" do
end
it "should be nil for en_address" do
computer.create(:name => :en_address)[:en_address].should == nil
computer.new(:name => :en_address)[:en_address].should == nil
end
it "should be nil for ip_address" do
computer.create(:name => :ip_address)[:ip_address].should == nil
computer.new(:name => :ip_address)[:ip_address].should == nil
end
end

Просмотреть файл

@ -7,7 +7,7 @@ module ExecModuleTesting
@user_name = 'some_user_name'
@group_name = 'some_group_name'
Puppet.features.stubs(:root?).returns(true)
@execer = Puppet::Type.type(:exec).create(:name => command, :path => %w{/usr/bin /bin}, :user => @user_name, :group => @group_name)
@execer = Puppet::Type.type(:exec).new(:name => command, :path => %w{/usr/bin /bin}, :user => @user_name, :group => @group_name)
status = stub "process"
status.stubs(:exitstatus).returns(exitstatus)

Просмотреть файл

@ -7,7 +7,7 @@ describe Puppet::Type.type(:file) do
@path = Tempfile.new("puppetspec")
@path.close!()
@path = @path.path
@file = Puppet::Type::File.create(:name => @path)
@file = Puppet::Type::File.new(:name => @path)
@catalog = mock 'catalog'
@catalog.stub_everything
@ -101,7 +101,7 @@ describe Puppet::Type.type(:file) do
File.open(@file, "w", 0644) { |f| f.puts "yayness"; f.flush }
File.symlink(@file, @link)
@resource = Puppet::Type.type(:file).create(
@resource = Puppet::Type.type(:file).new(
:path => @link,
:mode => "755"
)
@ -128,12 +128,12 @@ describe Puppet::Type.type(:file) do
end
it "should be able to retrieve a stat instance for the file it is managing" do
Puppet::Type.type(:file).create(:path => "/foo/bar", :source => "/bar/foo").should respond_to(:stat)
Puppet::Type.type(:file).new(:path => "/foo/bar", :source => "/bar/foo").should respond_to(:stat)
end
describe "when stat'ing its file" do
before do
@resource = Puppet::Type.type(:file).create(:path => "/foo/bar")
@resource = Puppet::Type.type(:file).new(:path => "/foo/bar")
@resource[:links] = :manage # so we always use :lstat
end
@ -197,13 +197,13 @@ describe Puppet::Type.type(:file) do
describe "when flushing" do
it "should flush all properties that respond to :flush" do
@resource = Puppet::Type.type(:file).create(:path => "/foo/bar", :source => "/bar/foo")
@resource = Puppet::Type.type(:file).new(:path => "/foo/bar", :source => "/bar/foo")
@resource.parameter(:source).expects(:flush)
@resource.flush
end
it "should reset its stat reference" do
@resource = Puppet::Type.type(:file).create(:path => "/foo/bar")
@resource = Puppet::Type.type(:file).new(:path => "/foo/bar")
File.expects(:lstat).times(2).returns("stat1").then.returns("stat2")
@resource.stat.should == "stat1"
@resource.flush
@ -593,7 +593,7 @@ describe Puppet::Type.type(:file) do
end
it "should not copy the parent resource's parent" do
Puppet::Type.type(:file).expects(:create).with { |options| ! options.include?(:parent) }
Puppet::Type.type(:file).expects(:new).with { |options| ! options.include?(:parent) }
@file.newchild("my/path")
end
@ -601,21 +601,21 @@ describe Puppet::Type.type(:file) do
it "should not pass on #{param} to the sub resource" do
@file[param] = value
@file.class.expects(:create).with { |params| params[param].nil? }
@file.class.expects(:new).with { |params| params[param].nil? }
@file.newchild("sub/file")
end
end
it "should copy all of the parent resource's 'should' values that were set at initialization" do
file = @file.class.create(:path => "/foo/bar", :owner => "root", :group => "wheel")
file = @file.class.new(:path => "/foo/bar", :owner => "root", :group => "wheel")
@catalog.add_resource(file)
file.class.expects(:create).with { |options| options[:owner] == "root" and options[:group] == "wheel" }
file.class.expects(:new).with { |options| options[:owner] == "root" and options[:group] == "wheel" }
file.newchild("my/path")
end
it "should not copy default values to the new child" do
@file.class.expects(:create).with { |params| params[:backup].nil? }
@file.class.expects(:new).with { |params| params[:backup].nil? }
@file.newchild("my/path")
end
@ -626,7 +626,7 @@ describe Puppet::Type.type(:file) do
@file.parameter(:source).copy_source_values
@file.class.expects(:create).with { |params| params[:group].nil? }
@file.class.expects(:new).with { |params| params[:group].nil? }
@file.newchild("my/path")
end
end

Просмотреть файл

@ -31,6 +31,6 @@ describe Puppet::Type.type(:group) do
# #1407 - we need to declare the allowdupe param as boolean.
it "should have a boolean method for determining if duplicates are allowed" do
@class.create(:name => "foo").methods.should be_include("allowdupe?")
@class.new(:name => "foo").methods.should be_include("allowdupe?")
end
end

Просмотреть файл

@ -52,19 +52,19 @@ describe Puppet::Type.type(:macauthorization), "when checking macauthorization o
it "should be able to create an instance" do
lambda {
macauth_type.create(:name => 'foo')
macauth_type.new(:name => 'foo')
}.should_not raise_error
end
it "should support :present as a value to :ensure" do
lambda {
macauth_type.create(:name => "foo", :ensure => :present)
macauth_type.new(:name => "foo", :ensure => :present)
}.should_not raise_error
end
it "should support :absent as a value to :ensure" do
lambda {
macauth_type.create(:name => "foo", :ensure => :absent)
macauth_type.new(:name => "foo", :ensure => :absent)
}.should_not raise_error
end

Просмотреть файл

@ -59,15 +59,15 @@ describe mcx_type, "default values" do
end
it "should be nil for :ds_type" do
mcx_type.create(:name => '/Foo/bar')[:ds_type].should be_nil
mcx_type.new(:name => '/Foo/bar')[:ds_type].should be_nil
end
it "should be nil for :ds_name" do
mcx_type.create(:name => '/Foo/bar')[:ds_name].should be_nil
mcx_type.new(:name => '/Foo/bar')[:ds_name].should be_nil
end
it "should be nil for :content" do
mcx_type.create(:name => '/Foo/bar')[:content].should be_nil
mcx_type.new(:name => '/Foo/bar')[:content].should be_nil
end
end
@ -81,19 +81,19 @@ describe mcx_type, "when validating properties" do
it "should be able to create an instance" do
lambda {
mcx_type.create(:name => '/Foo/bar')
mcx_type.new(:name => '/Foo/bar')
}.should_not raise_error
end
it "should support :present as a value to :ensure" do
lambda {
mcx_type.create(:name => "/Foo/bar", :ensure => :present)
mcx_type.new(:name => "/Foo/bar", :ensure => :present)
}.should_not raise_error
end
it "should support :absent as a value to :ensure" do
lambda {
mcx_type.create(:name => "/Foo/bar", :ensure => :absent)
mcx_type.new(:name => "/Foo/bar", :ensure => :absent)
}.should_not raise_error
end

Просмотреть файл

@ -8,7 +8,7 @@ describe Puppet::Type.type(:mount) do
end
it "should have no default value for :ensure" do
mount = Puppet::Type.type(:mount).create(:name => "yay")
mount = Puppet::Type.type(:mount).new(:name => "yay")
mount.should(:ensure).should be_nil
end
end
@ -34,20 +34,20 @@ describe Puppet::Type.type(:mount)::Ensure, "when validating values" do
end
it "should support :present as a value to :ensure" do
Puppet::Type.type(:mount).create(:name => "yay", :ensure => :present)
Puppet::Type.type(:mount).new(:name => "yay", :ensure => :present)
end
it "should alias :unmounted to :present as a value to :ensure" do
mount = Puppet::Type.type(:mount).create(:name => "yay", :ensure => :unmounted)
mount = Puppet::Type.type(:mount).new(:name => "yay", :ensure => :unmounted)
mount.should(:ensure).should == :present
end
it "should support :absent as a value to :ensure" do
Puppet::Type.type(:mount).create(:name => "yay", :ensure => :absent)
Puppet::Type.type(:mount).new(:name => "yay", :ensure => :absent)
end
it "should support :mounted as a value to :ensure" do
Puppet::Type.type(:mount).create(:name => "yay", :ensure => :mounted)
Puppet::Type.type(:mount).new(:name => "yay", :ensure => :mounted)
end
end
@ -55,7 +55,7 @@ describe Puppet::Type.type(:mount)::Ensure do
before :each do
@provider = stub 'provider', :class => Puppet::Type.type(:mount).defaultprovider, :clear => nil, :satisfies? => true, :name => :mock
Puppet::Type.type(:mount).defaultprovider.stubs(:new).returns(@provider)
@mount = Puppet::Type.type(:mount).create(:name => "yay", :check => :ensure)
@mount = Puppet::Type.type(:mount).new(:name => "yay", :check => :ensure)
@ensure = @mount.property(:ensure)
end
@ -185,7 +185,7 @@ describe Puppet::Type.type(:mount), "when modifying an existing mount entry" do
before do
@provider = stub 'provider', :class => Puppet::Type.type(:mount).defaultprovider, :clear => nil, :satisfies? => true, :name => :mock, :remount => nil
Puppet::Type.type(:mount).defaultprovider.stubs(:new).returns(@provider)
@mount = Puppet::Type.type(:mount).create(:name => "yay", :ensure => :mounted)
@mount = Puppet::Type.type(:mount).new(:name => "yay", :ensure => :mounted)
{:device => "/foo/bar", :blockdevice => "/other/bar", :target => "/what/ever", :fstype => 'eh', :options => "", :pass => 0, :dump => 0, :atboot => 0,
:ensure => :mounted}.each do

Просмотреть файл

@ -24,7 +24,7 @@ describe Puppet::Type.type(:package) do
end
it "should default to being installed" do
pkg = Puppet::Type.type(:package).create(:name => "yay")
pkg = Puppet::Type.type(:package).new(:name => "yay")
pkg.should(:ensure).should == :present
end
end
@ -48,50 +48,50 @@ describe Puppet::Type.type(:package), "when validating attribute values" do
end
it "should support :present as a value to :ensure" do
Puppet::Type.type(:package).create(:name => "yay", :ensure => :present)
Puppet::Type.type(:package).new(:name => "yay", :ensure => :present)
end
it "should alias :installed to :present as a value to :ensure" do
pkg = Puppet::Type.type(:package).create(:name => "yay", :ensure => :installed)
pkg = Puppet::Type.type(:package).new(:name => "yay", :ensure => :installed)
pkg.should(:ensure).should == :present
end
it "should support :absent as a value to :ensure" do
Puppet::Type.type(:package).create(:name => "yay", :ensure => :absent)
Puppet::Type.type(:package).new(:name => "yay", :ensure => :absent)
end
it "should support :purged as a value to :ensure if the provider has the :purgeable feature" do
@provider.expects(:satisfies?).with(:purgeable).returns(true)
Puppet::Type.type(:package).create(:name => "yay", :ensure => :purged)
Puppet::Type.type(:package).new(:name => "yay", :ensure => :purged)
end
it "should not support :purged as a value to :ensure if the provider does not have the :purgeable feature" do
@provider.expects(:satisfies?).with(:purgeable).returns(false)
proc { Puppet::Type.type(:package).create(:name => "yay", :ensure => :purged) }.should raise_error(Puppet::Error)
proc { Puppet::Type.type(:package).new(:name => "yay", :ensure => :purged) }.should raise_error(Puppet::Error)
end
it "should support :latest as a value to :ensure if the provider has the :upgradeable feature" do
@provider.expects(:satisfies?).with(:upgradeable).returns(true)
Puppet::Type.type(:package).create(:name => "yay", :ensure => :latest)
Puppet::Type.type(:package).new(:name => "yay", :ensure => :latest)
end
it "should not support :latest as a value to :ensure if the provider does not have the :upgradeable feature" do
@provider.expects(:satisfies?).with(:upgradeable).returns(false)
proc { Puppet::Type.type(:package).create(:name => "yay", :ensure => :latest) }.should raise_error(Puppet::Error)
proc { Puppet::Type.type(:package).new(:name => "yay", :ensure => :latest) }.should raise_error(Puppet::Error)
end
it "should support version numbers as a value to :ensure if the provider has the :versionable feature" do
@provider.expects(:satisfies?).with(:versionable).returns(true)
Puppet::Type.type(:package).create(:name => "yay", :ensure => "1.0")
Puppet::Type.type(:package).new(:name => "yay", :ensure => "1.0")
end
it "should not support version numbers as a value to :ensure if the provider does not have the :versionable feature" do
@provider.expects(:satisfies?).with(:versionable).returns(false)
proc { Puppet::Type.type(:package).create(:name => "yay", :ensure => "1.0") }.should raise_error(Puppet::Error)
proc { Puppet::Type.type(:package).new(:name => "yay", :ensure => "1.0") }.should raise_error(Puppet::Error)
end
it "should accept any string as an argument to :source" do
proc { Puppet::Type.type(:package).create(:name => "yay", :source => "stuff") }.should_not raise_error(Puppet::Error)
proc { Puppet::Type.type(:package).new(:name => "yay", :source => "stuff") }.should_not raise_error(Puppet::Error)
end
end
@ -106,7 +106,7 @@ describe Puppet::Type.type(:package) do
@provider = stub 'provider', :class => Puppet::Type.type(:package).defaultprovider, :clear => nil, :satisfies? => true, :name => :mock
Puppet::Type.type(:package).defaultprovider.stubs(:new).returns(@provider)
Puppet::Type.type(:package).defaultprovider.stubs(:instances).returns([])
@package = Puppet::Type.type(:package).create(:name => "yay")
@package = Puppet::Type.type(:package).new(:name => "yay")
@catalog = Puppet::Resource::Catalog.new
@catalog.add_resource(@package)

Просмотреть файл

@ -10,15 +10,15 @@ describe resources do
it "should fail if the specified resource type does not exist" do
Puppet::Type.stubs(:type).with("Resources").returns resources
Puppet::Type.expects(:type).with("nosuchtype").returns nil
lambda { resources.create :name => "nosuchtype" }.should raise_error(Puppet::Error)
lambda { resources.new :name => "nosuchtype" }.should raise_error(Puppet::Error)
end
it "should not fail when the specified resource type exists" do
lambda { resources.create :name => "file" }.should_not raise_error
lambda { resources.new :name => "file" }.should_not raise_error
end
it "should set its :resource_type attribute" do
resources.create(:name => "file").resource_type.should == Puppet::Type.type(:file)
resources.new(:name => "file").resource_type.should == Puppet::Type.type(:file)
end
end
end

Просмотреть файл

@ -43,7 +43,7 @@ describe Puppet::Type.type(:schedule) do
before :each do
Puppet.settings.stubs(:value).with(:ignoreschedules).returns(false)
@schedule = Puppet::Type.type(:schedule).create(:name => "testing")
@schedule = Puppet::Type.type(:schedule).new(:name => "testing")
end
describe Puppet::Type.type(:schedule) do

Просмотреть файл

@ -27,19 +27,19 @@ describe Puppet::Type.type(:selboolean), "when validating values" do
end
it "should support :on as a value to :value" do
Puppet::Type.type(:selboolean).create(:name => "yay", :value => :on)
Puppet::Type.type(:selboolean).new(:name => "yay", :value => :on)
end
it "should support :off as a value to :value" do
Puppet::Type.type(:selboolean).create(:name => "yay", :value => :off)
Puppet::Type.type(:selboolean).new(:name => "yay", :value => :off)
end
it "should support :true as a value to :persistent" do
Puppet::Type.type(:selboolean).create(:name => "yay", :value => :on, :persistent => :true)
Puppet::Type.type(:selboolean).new(:name => "yay", :value => :on, :persistent => :true)
end
it "should support :false as a value to :persistent" do
Puppet::Type.type(:selboolean).create(:name => "yay", :value => :on, :persistent => :false)
Puppet::Type.type(:selboolean).new(:name => "yay", :value => :on, :persistent => :false)
end
end

Просмотреть файл

@ -33,86 +33,86 @@ describe Puppet::Type.type(:service), "when validating attribute values" do
end
it "should support :running as a value to :ensure" do
Puppet::Type.type(:service).create(:name => "yay", :ensure => :running)
Puppet::Type.type(:service).new(:name => "yay", :ensure => :running)
end
it "should support :stopped as a value to :ensure" do
Puppet::Type.type(:service).create(:name => "yay", :ensure => :stopped)
Puppet::Type.type(:service).new(:name => "yay", :ensure => :stopped)
end
it "should alias the value :true to :running in :ensure" do
svc = Puppet::Type.type(:service).create(:name => "yay", :ensure => true)
svc = Puppet::Type.type(:service).new(:name => "yay", :ensure => true)
svc.should(:ensure).should == :running
end
it "should alias the value :false to :stopped in :ensure" do
svc = Puppet::Type.type(:service).create(:name => "yay", :ensure => false)
svc = Puppet::Type.type(:service).new(:name => "yay", :ensure => false)
svc.should(:ensure).should == :stopped
end
it "should support :true as a value to :enable" do
Puppet::Type.type(:service).create(:name => "yay", :enable => :true)
Puppet::Type.type(:service).new(:name => "yay", :enable => :true)
end
it "should support :false as a value to :enable" do
Puppet::Type.type(:service).create(:name => "yay", :enable => :false)
Puppet::Type.type(:service).new(:name => "yay", :enable => :false)
end
it "should support :true as a value to :hasstatus" do
Puppet::Type.type(:service).create(:name => "yay", :hasstatus => :true)
Puppet::Type.type(:service).new(:name => "yay", :hasstatus => :true)
end
it "should support :false as a value to :hasstatus" do
Puppet::Type.type(:service).create(:name => "yay", :hasstatus => :false)
Puppet::Type.type(:service).new(:name => "yay", :hasstatus => :false)
end
it "should support :true as a value to :hasrestart" do
Puppet::Type.type(:service).create(:name => "yay", :hasrestart => :true)
Puppet::Type.type(:service).new(:name => "yay", :hasrestart => :true)
end
it "should support :false as a value to :hasrestart" do
Puppet::Type.type(:service).create(:name => "yay", :hasrestart => :false)
Puppet::Type.type(:service).new(:name => "yay", :hasrestart => :false)
end
it "should allow setting the :enable parameter if the provider has the :enableable feature" do
Puppet::Type.type(:service).defaultprovider.stubs(:supports_parameter?).returns(true)
Puppet::Type.type(:service).defaultprovider.expects(:supports_parameter?).with(Puppet::Type.type(:service).attrclass(:enable)).returns(true)
svc = Puppet::Type.type(:service).create(:name => "yay", :enable => true)
svc = Puppet::Type.type(:service).new(:name => "yay", :enable => true)
svc.should(:enable).should == :true
end
it "should not allow setting the :enable parameter if the provider is missing the :enableable feature" do
Puppet::Type.type(:service).defaultprovider.stubs(:supports_parameter?).returns(true)
Puppet::Type.type(:service).defaultprovider.expects(:supports_parameter?).with(Puppet::Type.type(:service).attrclass(:enable)).returns(false)
svc = Puppet::Type.type(:service).create(:name => "yay", :enable => true)
svc = Puppet::Type.type(:service).new(:name => "yay", :enable => true)
svc.should(:enable).should be_nil
end
it "should discard paths that do not exist" do
FileTest.stubs(:exist?).returns(false)
FileTest.stubs(:directory?).returns(false)
svc = Puppet::Type.type(:service).create(:name => "yay", :path => "/one/two")
svc = Puppet::Type.type(:service).new(:name => "yay", :path => "/one/two")
svc[:path].should be_empty
end
it "should discard paths that are not directories" do
FileTest.stubs(:exist?).returns(true)
FileTest.stubs(:directory?).returns(false)
svc = Puppet::Type.type(:service).create(:name => "yay", :path => "/one/two")
svc = Puppet::Type.type(:service).new(:name => "yay", :path => "/one/two")
svc[:path].should be_empty
end
it "should split paths on ':'" do
FileTest.stubs(:exist?).returns(true)
FileTest.stubs(:directory?).returns(true)
svc = Puppet::Type.type(:service).create(:name => "yay", :path => "/one/two:/three/four")
svc = Puppet::Type.type(:service).new(:name => "yay", :path => "/one/two:/three/four")
svc[:path].should == %w{/one/two /three/four}
end
it "should accept arrays of paths joined by ':'" do
FileTest.stubs(:exist?).returns(true)
FileTest.stubs(:directory?).returns(true)
svc = Puppet::Type.type(:service).create(:name => "yay", :path => ["/one:/two", "/three:/four"])
svc = Puppet::Type.type(:service).new(:name => "yay", :path => ["/one:/two", "/three:/four"])
svc[:path].should == %w{/one /two /three /four}
end
end
@ -124,31 +124,31 @@ describe Puppet::Type.type(:service), "when setting default attribute values" do
Puppet::Type.type(:service).defaultprovider.stubs(:respond_to?).returns(true)
Puppet::Type.type(:service).defaultprovider.stubs(:defpath).returns("testing")
svc = Puppet::Type.type(:service).create(:name => "other")
svc = Puppet::Type.type(:service).new(:name => "other")
svc[:path].should == ["testing"]
end
it "should default 'pattern' to the binary if one is provided" do
svc = Puppet::Type.type(:service).create(:name => "other", :binary => "/some/binary")
svc = Puppet::Type.type(:service).new(:name => "other", :binary => "/some/binary")
svc[:pattern].should == "/some/binary"
end
it "should default 'pattern' to the name if no pattern is provided" do
svc = Puppet::Type.type(:service).create(:name => "other")
svc = Puppet::Type.type(:service).new(:name => "other")
svc[:pattern].should == "other"
end
it "should default 'control' to the upcased service name with periods replaced by underscores if the provider supports the 'controllable' feature" do
provider = stub 'provider', :controllable? => true, :class => Puppet::Type.type(:service).defaultprovider, :clear => nil
Puppet::Type.type(:service).defaultprovider.stubs(:new).returns(provider)
svc = Puppet::Type.type(:service).create(:name => "nfs.client")
svc = Puppet::Type.type(:service).new(:name => "nfs.client")
svc[:control].should == "NFS_CLIENT_START"
end
end
describe Puppet::Type.type(:service), "when retrieving the host's current state" do
before do
@service = Puppet::Type.type(:service).create(:name => "yay")
@service = Puppet::Type.type(:service).new(:name => "yay")
end
it "should use the provider's status to determine whether the service is running" do
@ -167,7 +167,7 @@ end
describe Puppet::Type.type(:service), "when changing the host" do
before do
@service = Puppet::Type.type(:service).create(:name => "yay")
@service = Puppet::Type.type(:service).new(:name => "yay")
end
it "should start the service if it is supposed to be running" do
@ -213,7 +213,7 @@ end
describe Puppet::Type.type(:service), "when refreshing the service" do
before do
@service = Puppet::Type.type(:service).create(:name => "yay")
@service = Puppet::Type.type(:service).new(:name => "yay")
end
it "should restart the service if it is running" do

Просмотреть файл

@ -34,31 +34,31 @@ describe ssh_authorized_key do
end
it "should support :present as a value for :ensure" do
proc { @class.create(:name => "whev", :ensure => :present, :user => "nobody") }.should_not raise_error
proc { @class.new(:name => "whev", :ensure => :present, :user => "nobody") }.should_not raise_error
end
it "should support :absent as a value for :ensure" do
proc { @class.create(:name => "whev", :ensure => :absent, :user => "nobody") }.should_not raise_error
proc { @class.new(:name => "whev", :ensure => :absent, :user => "nobody") }.should_not raise_error
end
it "should have an type property" do
@class.attrtype(:type).should == :property
end
it "should support ssh-dss as an type value" do
proc { @class.create(:name => "whev", :type => "ssh-dss", :user => "nobody") }.should_not raise_error
proc { @class.new(:name => "whev", :type => "ssh-dss", :user => "nobody") }.should_not raise_error
end
it "should support ssh-rsa as an type value" do
proc { @class.create(:name => "whev", :type => "ssh-rsa", :user => "nobody") }.should_not raise_error
proc { @class.new(:name => "whev", :type => "ssh-rsa", :user => "nobody") }.should_not raise_error
end
it "should support :dsa as an type value" do
proc { @class.create(:name => "whev", :type => :dsa, :user => "nobody") }.should_not raise_error
proc { @class.new(:name => "whev", :type => :dsa, :user => "nobody") }.should_not raise_error
end
it "should support :rsa as an type value" do
proc { @class.create(:name => "whev", :type => :rsa, :user => "nobody") }.should_not raise_error
proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody") }.should_not raise_error
end
it "should not support values other than ssh-dss, ssh-rsa, dsa, rsa in the ssh_authorized_key_type" do
proc { @class.create(:name => "whev", :type => :something) }.should raise_error(Puppet::Error)
proc { @class.new(:name => "whev", :type => :something) }.should raise_error(Puppet::Error)
end
it "should have an key property" do
@ -74,13 +74,13 @@ describe ssh_authorized_key do
end
it "'s options property should return well formed string of arrays from is_to_s" do
resource = @class.create(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"])
resource = @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"])
resource.property(:options).is_to_s(["a","b","c"]).should == "a,b,c"
end
it "'s options property should return well formed string of arrays from is_to_s" do
resource = @class.create(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"])
resource = @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"])
resource.property(:options).should_to_s(["a","b","c"]).should == "a,b,c"
end
@ -91,7 +91,7 @@ describe ssh_authorized_key do
it "should raise an error when neither user nor target is given" do
proc do
@class.create(
@class.new(
:name => "Test",
:key => "AAA",
:type => "ssh-rsa",

Просмотреть файл

@ -4,7 +4,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
describe Puppet::Type.type(:tidy) do
it "should use :lstat when stating a file" do
tidy = Puppet::Type.type(:tidy).create :path => "/foo/bar", :age => "1d"
tidy = Puppet::Type.type(:tidy).new :path => "/foo/bar", :age => "1d"
stat = mock 'stat'
File.expects(:lstat).with("/foo/bar").returns stat
tidy.stat("/foo/bar").should == stat
@ -23,7 +23,7 @@ describe Puppet::Type.type(:tidy) do
describe "when validating parameter values" do
describe "for 'recurse'" do
before do
@tidy = Puppet::Type.type(:tidy).create :path => "/tmp", :age => "100d"
@tidy = Puppet::Type.type(:tidy).new :path => "/tmp", :age => "100d"
end
it "should allow 'true'" do
@ -64,7 +64,7 @@ describe Puppet::Type.type(:tidy) do
convertors.each do |unit, multiple|
it "should consider a %s to be %s seconds" % [unit, multiple] do
tidy = Puppet::Type.type(:tidy).create :path => "/what/ever", :age => "5%s" % unit.to_s[0..0]
tidy = Puppet::Type.type(:tidy).new :path => "/what/ever", :age => "5%s" % unit.to_s[0..0]
tidy[:age].should == 5 * multiple
end
@ -81,7 +81,7 @@ describe Puppet::Type.type(:tidy) do
convertors.each do |unit, multiple|
it "should consider a %s to be 1024^%s bytes" % [unit, multiple] do
tidy = Puppet::Type.type(:tidy).create :path => "/what/ever", :size => "5%s" % unit
tidy = Puppet::Type.type(:tidy).new :path => "/what/ever", :size => "5%s" % unit
total = 5
multiple.times { total *= 1024 }
@ -92,7 +92,7 @@ describe Puppet::Type.type(:tidy) do
describe "when tidying" do
before do
@tidy = Puppet::Type.type(:tidy).create :path => "/what/ever"
@tidy = Puppet::Type.type(:tidy).new :path => "/what/ever"
@stat = stub 'stat', :ftype => "directory"
File.stubs(:lstat).with("/what/ever").returns @stat
end
@ -100,25 +100,25 @@ describe Puppet::Type.type(:tidy) do
describe "and generating files" do
it "should set the backup on the file if backup is set on the tidy instance" do
@tidy[:backup] = "whatever"
Puppet::Type.type(:file).expects(:create).with { |args| args[:backup] == "whatever" }
Puppet::Type.type(:file).expects(:new).with { |args| args[:backup] == "whatever" }
@tidy.mkfile("/what/ever")
end
it "should set the file's path to the tidy's path" do
Puppet::Type.type(:file).expects(:create).with { |args| args[:path] == "/what/ever" }
Puppet::Type.type(:file).expects(:new).with { |args| args[:path] == "/what/ever" }
@tidy.mkfile("/what/ever")
end
it "should configure the file for deletion" do
Puppet::Type.type(:file).expects(:create).with { |args| args[:ensure] == :absent }
Puppet::Type.type(:file).expects(:new).with { |args| args[:ensure] == :absent }
@tidy.mkfile("/what/ever")
end
it "should force deletion on the file" do
Puppet::Type.type(:file).expects(:create).with { |args| args[:force] == true }
Puppet::Type.type(:file).expects(:new).with { |args| args[:force] == true }
@tidy.mkfile("/what/ever")
end
@ -133,7 +133,7 @@ describe Puppet::Type.type(:tidy) do
describe "and recursion is not used" do
it "should generate a file resource if the file should be tidied" do
@tidy.expects(:tidy?).with("/what/ever").returns true
file = Puppet::Type.type(:file).create(:path => "/eh")
file = Puppet::Type.type(:file).new(:path => "/eh")
@tidy.expects(:mkfile).with("/what/ever").returns file
@tidy.generate.should == [file]
@ -170,7 +170,7 @@ describe Puppet::Type.type(:tidy) do
@tidy.expects(:tidy?).with("/what/ever/one").returns true
@tidy.expects(:tidy?).with("/what/ever/two").returns false
file = Puppet::Type.type(:file).create(:path => "/eh")
file = Puppet::Type.type(:file).new(:path => "/eh")
@tidy.expects(:mkfile).with("/what/ever").returns file
@tidy.expects(:mkfile).with("/what/ever/one").returns file
@ -180,7 +180,7 @@ describe Puppet::Type.type(:tidy) do
describe "and determining whether a file matches provided glob patterns" do
before do
@tidy = Puppet::Type.type(:tidy).create :path => "/what/ever"
@tidy = Puppet::Type.type(:tidy).new :path => "/what/ever"
@tidy[:matches] = %w{*foo* *bar*}
@stat = mock 'stat'
@ -206,7 +206,7 @@ describe Puppet::Type.type(:tidy) do
describe "and determining whether a file is too old" do
before do
@tidy = Puppet::Type.type(:tidy).create :path => "/what/ever"
@tidy = Puppet::Type.type(:tidy).new :path => "/what/ever"
@stat = stub 'stat'
@tidy[:age] = "1s"
@ -236,7 +236,7 @@ describe Puppet::Type.type(:tidy) do
describe "and determining whether a file is too large" do
before do
@tidy = Puppet::Type.type(:tidy).create :path => "/what/ever"
@tidy = Puppet::Type.type(:tidy).new :path => "/what/ever"
@stat = stub 'stat', :ftype => "file"
@tidy[:size] = "1kb"
@ -258,7 +258,7 @@ describe Puppet::Type.type(:tidy) do
describe "and determining whether a file should be tidied" do
before do
@tidy = Puppet::Type.type(:tidy).create :path => "/what/ever"
@tidy = Puppet::Type.type(:tidy).new :path => "/what/ever"
@stat = stub 'stat', :ftype => "file"
File.stubs(:lstat).with("/what/ever").returns @stat
end

Просмотреть файл

@ -15,7 +15,7 @@ describe user do
end
it "should be able to create a instance" do
user.create(:name => "foo").should_not be_nil
user.new(:name => "foo").should_not be_nil
end
it "should have an allows_duplicates feature" do
@ -36,7 +36,7 @@ describe user do
describe "instances" do
it "should have a valid provider" do
user.create(:name => "foo").provider.class.ancestors.should be_include(Puppet::Provider)
user.new(:name => "foo").provider.class.ancestors.should be_include(Puppet::Provider)
end
end
@ -70,7 +70,7 @@ describe user do
describe "when retrieving all current values" do
before do
@user = user.create(:name => "foo", :uid => 10, :gid => 10)
@user = user.new(:name => "foo", :uid => 10, :gid => 10)
end
it "should return a hash containing values for all set properties" do
@ -239,11 +239,11 @@ describe user do
describe "when user has roles" do
it "should autorequire roles" do
#this is a little funky because the autorequire depends on a property with a feature
testuser = Puppet::Type.type(:user).create(:name => "testuser")
testuser = Puppet::Type.type(:user).new(:name => "testuser")
testuser.provider.class.expects(:feature?).with(:manages_solaris_rbac).returns(true)
testuser[:roles] = "testrole"
testrole = Puppet::Type.type(:user).create(:name => "testrole")
testrole = Puppet::Type.type(:user).new(:name => "testrole")
config = Puppet::Resource::Catalog.new :testing do |conf|
[testuser, testrole].each { |resource| conf.add_resource resource }

Просмотреть файл

@ -28,11 +28,11 @@ describe zfs do
Puppet::Type.type(:zpool).stubs(:defaultprovider).returns(provider)
foo_pool = Puppet::Type.type(:zpool).create(:name => "foo")
foo_pool = Puppet::Type.type(:zpool).new(:name => "foo")
foo_bar_zfs = Puppet::Type.type(:zfs).create(:name => "foo/bar")
foo_bar_baz_zfs = Puppet::Type.type(:zfs).create(:name => "foo/bar/baz")
foo_bar_baz_buz_zfs = Puppet::Type.type(:zfs).create(:name => "foo/bar/baz/buz")
foo_bar_zfs = Puppet::Type.type(:zfs).new(:name => "foo/bar")
foo_bar_baz_zfs = Puppet::Type.type(:zfs).new(:name => "foo/bar/baz")
foo_bar_baz_buz_zfs = Puppet::Type.type(:zfs).new(:name => "foo/bar/baz/buz")
config = Puppet::Resource::Catalog.new :testing do |conf|
[foo_pool, foo_bar_zfs, foo_bar_baz_zfs, foo_bar_baz_buz_zfs].each { |resource| conf.add_resource resource }

Просмотреть файл

@ -37,8 +37,8 @@ describe Puppet::Util::Storage do
describe "when caching a Puppet::Type" do
before(:all) do
@file_test = Puppet::Type.type(:file).create(:name => "/yayness", :check => %w{checksum type})
@exec_test = Puppet::Type.type(:exec).create(:name => "/bin/ls /yayness")
@file_test = Puppet::Type.type(:file).new(:name => "/yayness", :check => %w{checksum type})
@exec_test = Puppet::Type.type(:exec).new(:name => "/bin/ls /yayness")
end
it "should return an empty hash" do

Просмотреть файл

@ -5,7 +5,7 @@
module PuppetTest::Support::Resources
def tree_resource(name)
Puppet::Type.type(:file).create :title => name, :path => "/tmp/#{name}", :mode => 0755
Puppet::Type.type(:file).new :title => name, :path => "/tmp/#{name}", :mode => 0755
end
def tree_container(name)

Просмотреть файл

@ -269,7 +269,7 @@ end
user = nonrootuser()
group = nonrootgroup()
chowner = Puppet::Type.type(:file).create :path => dir,
chowner = Puppet::Type.type(:file).new :path => dir,
:owner => user.name, :group => group.name, :recurse => true
assert_apply(chowner)
chowner.remove

Просмотреть файл

@ -11,11 +11,11 @@ class TestEvents < Test::Unit::TestCase
def test_simplesubscribe
name = tempfile()
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:name => name,
:ensure => "file"
)
exec = Puppet::Type.type(:exec).create(
exec = Puppet::Type.type(:exec).new(
:name => "echo true",
:path => "/usr/bin:/bin",
:refreshonly => true,
@ -31,11 +31,11 @@ class TestEvents < Test::Unit::TestCase
def test_simplerequire
name = tempfile()
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:name => name,
:ensure => "file"
)
exec = Puppet::Type.type(:exec).create(
exec = Puppet::Type.type(:exec).new(
:name => "echo true",
:path => "/usr/bin:/bin",
:refreshonly => true,
@ -57,14 +57,14 @@ class TestEvents < Test::Unit::TestCase
files = []
4.times { |i|
files << Puppet::Type.type(:file).create(
files << Puppet::Type.type(:file).new(
:name => tempfile(),
:ensure => "file"
)
}
fname = tempfile()
exec = Puppet::Type.type(:exec).create(
exec = Puppet::Type.type(:exec).new(
:name => "touch %s" % fname,
:path => "/usr/bin:/bin",
:refreshonly => true
@ -84,13 +84,13 @@ class TestEvents < Test::Unit::TestCase
def test_refreshordering
file = tempfile()
exec1 = Puppet::Type.type(:exec).create(
exec1 = Puppet::Type.type(:exec).new(
:title => "one",
:name => "echo one >> %s" % file,
:path => "/usr/bin:/bin"
)
exec2 = Puppet::Type.type(:exec).create(
exec2 = Puppet::Type.type(:exec).new(
:title => "two",
:name => "echo two >> %s" % file,
:path => "/usr/bin:/bin",
@ -98,7 +98,7 @@ class TestEvents < Test::Unit::TestCase
:subscribe => exec1
)
exec3 = Puppet::Type.type(:exec).create(
exec3 = Puppet::Type.type(:exec).new(
:title => "three",
:name => "echo three >> %s" % file,
:path => "/usr/bin:/bin",

Просмотреть файл

@ -24,7 +24,7 @@ class TestOverrides < Test::Unit::TestCase
mksubdirs(basedir, 1)
basefile = File.join(basedir, "file")
baseobj = Puppet::Type.type(:file).create(
baseobj = Puppet::Type.type(:file).new(
:title => "base",
:path => basedir,
:recurse => true,
@ -33,7 +33,7 @@ class TestOverrides < Test::Unit::TestCase
subdir = File.join(basedir, "0")
subfile = File.join(subdir, "file")
subobj = Puppet::Type.type(:file).create(
subobj = Puppet::Type.type(:file).new(
:title => "sub",
:path => subdir,
:recurse => true,
@ -52,7 +52,7 @@ class TestOverrides < Test::Unit::TestCase
baseobj = nil
assert_nothing_raised("Could not create base obj") {
baseobj = Puppet::Type.type(:file).create(
baseobj = Puppet::Type.type(:file).new(
:path => basedir,
:recurse => true,
:mode => "755"
@ -76,7 +76,7 @@ class TestOverrides < Test::Unit::TestCase
end
assert_nothing_raised("Could not create sub obj") {
children << Puppet::Type.type(:file).create(
children << Puppet::Type.type(:file).new(
:path => subdir,
:recurse => true,
:mode => mode

Просмотреть файл

@ -14,7 +14,7 @@ class TestRelationships < Test::Unit::TestCase
def newfile
assert_nothing_raised() {
return Puppet::Type.type(:file).create(
return Puppet::Type.type(:file).new(
:path => tempfile,
:check => [:mode, :owner, :group]
)

Просмотреть файл

@ -21,7 +21,7 @@ class TestReports < Test::Unit::TestCase
# Make every third file
File.open(file, "w") { |f| f.puts "" } if i % 3 == 0
objects << Puppet::Type.type(:file).create(
objects << Puppet::Type.type(:file).new(
:path => file,
:ensure => "file"
)
@ -44,7 +44,7 @@ class TestReports < Test::Unit::TestCase
}
# Now make a file for testing logging
file = Puppet::Type.type(:file).create(:path => tempfile(), :ensure => "file")
file = Puppet::Type.type(:file).new(:path => tempfile(), :ensure => "file")
file.finish
log = nil

Просмотреть файл

@ -53,7 +53,7 @@ class TestTransactions < Test::Unit::TestCase
def eval_generate
ret = []
if title.length > 1
ret << self.class.create(:title => title[0..-2])
ret << self.class.new(:title => title[0..-2])
else
return nil
end
@ -72,11 +72,11 @@ class TestTransactions < Test::Unit::TestCase
path1 = tempfile()
path2 = tempfile()
objects = []
objects << Puppet::Type.type(:file).create(
objects << Puppet::Type.type(:file).new(
:path => path1,
:content => "yayness"
)
objects << Puppet::Type.type(:file).create(
objects << Puppet::Type.type(:file).new(
:path => path2,
:content => "booness"
)
@ -130,7 +130,7 @@ class TestTransactions < Test::Unit::TestCase
end
# Now create an instance
inst = type.create :name => "yay"
inst = type.new :name => "yay"
# Create a transaction
trans = Puppet::Transaction.new(mk_catalog(inst))
@ -155,13 +155,13 @@ class TestTransactions < Test::Unit::TestCase
path = tempfile()
firstpath = tempfile()
secondpath = tempfile()
file = Puppet::Type.type(:file).create(:title => "file", :path => path, :content => "yayness")
first = Puppet::Type.type(:exec).create(:title => "first",
file = Puppet::Type.type(:file).new(:title => "file", :path => path, :content => "yayness")
first = Puppet::Type.type(:exec).new(:title => "first",
:command => "/bin/echo first > #{firstpath}",
:subscribe => [:file, path],
:refreshonly => true
)
second = Puppet::Type.type(:exec).create(:title => "second",
second = Puppet::Type.type(:exec).new(:title => "second",
:command => "/bin/echo second > #{secondpath}",
:subscribe => [:exec, "first"],
:refreshonly => true
@ -219,13 +219,13 @@ class TestTransactions < Test::Unit::TestCase
hash[:name] = tmpfile
assert_nothing_raised() {
return Puppet::Type.type(:file).create(hash)
return Puppet::Type.type(:file).new(hash)
}
end
def newexec(file)
assert_nothing_raised() {
return Puppet::Type.type(:exec).create(
return Puppet::Type.type(:exec).new(
:name => "touch %s" % file,
:path => "/bin:/usr/bin:/sbin:/usr/sbin",
:returns => 0
@ -347,12 +347,12 @@ class TestTransactions < Test::Unit::TestCase
assert_apply(file)
config = Puppet::Resource::Catalog.new
fcomp = Puppet::Type.type(:component).create(:name => "file")
fcomp = Puppet::Type.type(:component).new(:name => "file")
config.add_resource fcomp
config.add_resource file
config.add_edge(fcomp, file)
ecomp = Puppet::Type.type(:component).create(:name => "exec")
ecomp = Puppet::Type.type(:component).new(:name => "exec")
config.add_resource ecomp
config.add_resource exec
config.add_edge(ecomp, exec)
@ -377,17 +377,17 @@ class TestTransactions < Test::Unit::TestCase
path = tempfile()
file1 = tempfile()
file2 = tempfile()
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:path => path,
:ensure => "file"
)
exec1 = Puppet::Type.type(:exec).create(
exec1 = Puppet::Type.type(:exec).new(
:path => ENV["PATH"],
:command => "touch %s" % file1,
:refreshonly => true,
:subscribe => [:file, path]
)
exec2 = Puppet::Type.type(:exec).create(
exec2 = Puppet::Type.type(:exec).new(
:path => ENV["PATH"],
:command => "touch %s" % file2,
:refreshonly => true,
@ -404,11 +404,11 @@ class TestTransactions < Test::Unit::TestCase
def test_failedrefreshes
path = tempfile()
newfile = tempfile()
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:path => path,
:ensure => "file"
)
exec1 = Puppet::Type.type(:exec).create(
exec1 = Puppet::Type.type(:exec).new(
:path => ENV["PATH"],
:command => "touch /this/cannot/possibly/exist",
:logoutput => true,
@ -416,7 +416,7 @@ class TestTransactions < Test::Unit::TestCase
:subscribe => file,
:title => "one"
)
exec2 = Puppet::Type.type(:exec).create(
exec2 = Puppet::Type.type(:exec).new(
:path => ENV["PATH"],
:command => "touch %s" % newfile,
:logoutput => true,
@ -433,14 +433,14 @@ class TestTransactions < Test::Unit::TestCase
def test_unscheduled_and_untagged_response
Puppet::Type.type(:schedule).mkdefaultschedules
Puppet[:ignoreschedules] = false
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:name => tempfile(),
:ensure => "file",
:backup => false
)
fname = tempfile()
exec = Puppet::Type.type(:exec).create(
exec = Puppet::Type.type(:exec).new(
:name => "touch %s" % fname,
:path => "/usr/bin:/bin",
:schedule => "monthly",
@ -484,19 +484,19 @@ class TestTransactions < Test::Unit::TestCase
end
def test_failed_reqs_mean_no_run
exec = Puppet::Type.type(:exec).create(
exec = Puppet::Type.type(:exec).new(
:command => "/bin/mkdir /this/path/cannot/possibly/exit",
:title => "mkdir"
)
file1 = Puppet::Type.type(:file).create(
file1 = Puppet::Type.type(:file).new(
:title => "file1",
:path => tempfile(),
:require => exec,
:ensure => :file
)
file2 = Puppet::Type.type(:file).create(
file2 = Puppet::Type.type(:file).new(
:title => "file2",
:path => tempfile(),
:require => file1,
@ -527,7 +527,7 @@ class TestTransactions < Test::Unit::TestCase
trans.prepare
return
resource = Puppet::Type.type(:file).create :ensure => :present, :path => tempfile()
resource = Puppet::Type.type(:file).new :ensure => :present, :path => tempfile()
other_resource = mock 'generated'
def resource.generate
[other_resource]
@ -599,7 +599,7 @@ class TestTransactions < Test::Unit::TestCase
end
end
resource = type.create :name => "test"
resource = type.new :name => "test"
config = mk_catalog(resource)
trans = Puppet::Transaction.new(config)
trans.prepare
@ -627,8 +627,8 @@ class TestTransactions < Test::Unit::TestCase
File.chmod(0644, file)
File.chmod(0755, dir) # So only the child file causes a change
dirobj = Puppet::Type.type(:file).create :mode => "755", :recurse => true, :path => dir
exec = Puppet::Type.type(:exec).create :title => "make",
dirobj = Puppet::Type.type(:file).new :mode => "755", :recurse => true, :path => dir
exec = Puppet::Type.type(:exec).new :title => "make",
:command => "touch #{maker}", :path => ENV['PATH'], :refreshonly => true,
:subscribe => dirobj
@ -712,9 +712,9 @@ class TestTransactions < Test::Unit::TestCase
end
def test_set_target
file = Puppet::Type.type(:file).create(:path => tempfile(), :content => "yay")
exec1 = Puppet::Type.type(:exec).create :command => "/bin/echo exec1"
exec2 = Puppet::Type.type(:exec).create :command => "/bin/echo exec2"
file = Puppet::Type.type(:file).new(:path => tempfile(), :content => "yay")
exec1 = Puppet::Type.type(:exec).new :command => "/bin/echo exec1"
exec2 = Puppet::Type.type(:exec).new :command => "/bin/echo exec2"
trans = Puppet::Transaction.new(mk_catalog(file, exec1, exec2))
# First try it with an edge that has no callback
@ -747,8 +747,8 @@ class TestTransactions < Test::Unit::TestCase
Puppet::Type.rmtype(:norefresh)
end
file = Puppet::Type.type(:file).create :path => tempfile(), :content => "yay"
one = klass.create :name => "one", :subscribe => file
file = Puppet::Type.type(:file).new :path => tempfile(), :content => "yay"
one = klass.new :name => "one", :subscribe => file
assert_apply(file, one)
@ -757,8 +757,8 @@ class TestTransactions < Test::Unit::TestCase
# Testing #437 - cyclic graphs should throw failures.
def test_fail_on_cycle
one = Puppet::Type.type(:exec).create(:name => "/bin/echo one")
two = Puppet::Type.type(:exec).create(:name => "/bin/echo two")
one = Puppet::Type.type(:exec).new(:name => "/bin/echo one")
two = Puppet::Type.type(:exec).new(:name => "/bin/echo two")
one[:require] = two
two[:require] = one
@ -781,7 +781,7 @@ class TestTransactions < Test::Unit::TestCase
end
cleanup { Puppet::Type.rmtype(:failer) }
obj = type.create(:name => "testing")
obj = type.new(:name => "testing")
assert_apply(obj)
end
@ -802,7 +802,7 @@ class TestTransactions < Test::Unit::TestCase
end
cleanup { Puppet::Type.rmtype(:refresher)}
obj = type.create(:name => "yay", :testing => "cool")
obj = type.new(:name => "yay", :testing => "cool")
assert(! obj.insync?(obj.retrieve), "fake object is already in sync")
@ -816,8 +816,8 @@ class TestTransactions < Test::Unit::TestCase
# Create a couple of different resource sets that have automatic relationships and make sure the manual relationships win
rels = {}
# First users and groups
group = Puppet::Type.type(:group).create(:name => nonrootgroup.name, :ensure => :present)
user = Puppet::Type.type(:user).create(:name => nonrootuser.name, :ensure => :present, :gid => group.title)
group = Puppet::Type.type(:group).new(:name => nonrootgroup.name, :ensure => :present)
user = Puppet::Type.type(:user).new(:name => nonrootuser.name, :ensure => :present, :gid => group.title)
# Now add the explicit relationship
group[:require] = user
@ -825,8 +825,8 @@ class TestTransactions < Test::Unit::TestCase
# Now files
d = tempfile()
f = File.join(d, "file")
file = Puppet::Type.type(:file).create(:path => f, :content => "yay")
dir = Puppet::Type.type(:file).create(:path => d, :ensure => :directory, :require => file)
file = Puppet::Type.type(:file).new(:path => f, :content => "yay")
dir = Puppet::Type.type(:file).new(:path => d, :ensure => :directory, :require => file)
rels[dir] = file
rels.each do |after, before|
@ -850,12 +850,12 @@ class TestTransactions < Test::Unit::TestCase
path = tempfile
epath = tempfile
spath = tempfile
file = Puppet::Type.type(:file).create(:path => path, :ensure => :file,
file = Puppet::Type.type(:file).new(:path => path, :ensure => :file,
:title => "file")
exec = Puppet::Type.type(:exec).create(:command => "touch %s" % epath,
exec = Puppet::Type.type(:exec).new(:command => "touch %s" % epath,
:path => ENV["PATH"], :subscribe => file, :refreshonly => true,
:title => 'exec1')
exec2 = Puppet::Type.type(:exec).create(:command => "touch %s" % spath,
exec2 = Puppet::Type.type(:exec).new(:command => "touch %s" % spath,
:path => ENV["PATH"], :subscribe => exec, :refreshonly => true,
:title => 'exec2')
@ -888,7 +888,7 @@ class TestTransactions < Test::Unit::TestCase
3.times do |i|
path = tempfile
paths << path
file = Puppet::Type.type(:file).create(:path => path, :ensure => :absent,
file = Puppet::Type.type(:file).new(:path => path, :ensure => :absent,
:backup => false, :title => "file%s" % i)
File.open(path, "w") { |f| f.puts "" }
files << file
@ -929,7 +929,7 @@ class TestTransactions < Test::Unit::TestCase
cleanup { Puppet::Type.rmtype(:flushtest) }
obj = type.create(:name => "test", :ensure => :present)
obj = type.new(:name => "test", :ensure => :present)
# first make sure it runs through and flushes
assert_apply(obj)

Просмотреть файл

@ -29,7 +29,7 @@ class TestTypeAttributes < Test::Unit::TestCase
# and a param
type.newparam(:param)
inst = type.create(:name => "yay")
inst = type.new(:name => "yay")
# Make sure we can set each of them, including a metaparam
[:param, :property, :noop].each do |param|
@ -66,7 +66,7 @@ class TestTypeAttributes < Test::Unit::TestCase
type.newproperty(prop) {}
end
inst = type.create(:name => "yay")
inst = type.new(:name => "yay")
inst[:one] = "boo"
one = inst.property(:one)
@ -88,7 +88,7 @@ class TestTypeAttributes < Test::Unit::TestCase
@num ||= 0
@num += 1
name = "name%s" % @num
inst = type.create(:name => name)
inst = type.new(:name => name)
[:meta, :param, :prop].each do |name|
klass = type.attrclass(name)
assert(klass, "did not get class for %s" % name)
@ -162,7 +162,7 @@ class TestTypeAttributes < Test::Unit::TestCase
assert_nil(type.attr_alias(:name), "got invalid alias info for name")
inst = type.create(:name => "my name")
inst = type.new(:name => "my name")
assert(inst, "could not create instance")
aliases.each do |new, old|
@ -227,7 +227,7 @@ class TestTypeAttributes < Test::Unit::TestCase
# Now make sure that we get warnings and no properties in those cases where our providers do not support the features requested
[nope, maybe, yep].each_with_index do |prov, i|
resource = type.create(:provider => prov.name, :name => "test%s" % i, :none => "a", :one => "b", :two => "c")
resource = type.new(:provider => prov.name, :name => "test%s" % i, :none => "a", :one => "b", :two => "c")
case prov.name
when :nope:
@ -257,7 +257,7 @@ class TestTypeAttributes < Test::Unit::TestCase
file = Puppet::Type.type(:file)
klass = file.attrclass(:check)
resource = file.create(:path => tempfile)
resource = file.new(:path => tempfile)
inst = klass.new(:resource => resource)
{:property => [:owner, :group], :parameter => [:ignore, :recurse], :metaparam => [:require, :subscribe]}.each do |attrtype, attrs|
@ -308,7 +308,7 @@ class TestTypeAttributes < Test::Unit::TestCase
end
cleanup { Puppet::Type.rmtype(:unsupported) }
obj = type.create(:name => "test", :check => :yep)
obj = type.new(:name => "test", :check => :yep)
obj.expects(:newattr).with(:nope).never
obj[:check] = :all
end

Просмотреть файл

@ -64,9 +64,9 @@ class TestTypeInstances < Test::Unit::TestCase
# Now make a couple of instances, so we know we correctly match instead of always
# trying to create new ones.
one = @type.create(:name => :one, :ensure => :present)
three = @type.create(:name => :three, :ensure => :present, :provider => :sub)
five = @type.create(:name => :five, :ensure => :present, :provider => :yep)
one = @type.new(:name => :one, :ensure => :present)
three = @type.new(:name => :three, :ensure => :present, :provider => :sub)
five = @type.new(:name => :five, :ensure => :present, :provider => :yep)
result = nil
assert_nothing_raised("Could not get instance list") do

Просмотреть файл

@ -54,7 +54,7 @@ class TestTypeProviders < Test::Unit::TestCase
# first make sure we can pass the name in
resource = nil
assert_nothing_raised("Could not create provider instance by name") do
resource = @type.create :name => "yay", :provider => :testing
resource = @type.new :name => "yay", :provider => :testing
end
assert_instance_of(provider, resource.provider, "Did not create provider instance")
@ -62,7 +62,7 @@ class TestTypeProviders < Test::Unit::TestCase
# Now make sure we can pass in an instance
provinst = provider.new(:name => "foo")
assert_nothing_raised("Could not pass in provider instance") do
resource = @type.create :name => "foo", :provider => provinst
resource = @type.new :name => "foo", :provider => provinst
end
assert_equal(provinst, resource.provider, "Did not retain provider instance")
@ -74,11 +74,11 @@ class TestTypeProviders < Test::Unit::TestCase
end
# And make sure the provider must be a valid provider type for this resource
pkgprov = Puppet::Type.type(:package).create(:name => "yayness").provider
pkgprov = Puppet::Type.type(:package).new(:name => "yayness").provider
assert(provider, "did not get package provider")
assert_raise(Puppet::Error, "Did not fail on invalid provider instance") do
resource = @type.create :name => "bar", :provider => pkgprov
resource = @type.new :name => "bar", :provider => pkgprov
end
end
@ -89,7 +89,7 @@ class TestTypeProviders < Test::Unit::TestCase
Puppet::Type.type(:user).provider(:useradd).stubs(:suitable?).returns false
assert_nothing_raised("Unsuitable providers failed at initialization") do
Puppet::Type.type(:user).create :name => "luke", :ensure => :present, :provider => :useradd
Puppet::Type.type(:user).new :name => "luke", :ensure => :present, :provider => :useradd
end
end
@ -98,7 +98,7 @@ class TestTypeProviders < Test::Unit::TestCase
def test_unsuitable_providers_should_fail_at_evaluation
Puppet::Type.type(:user).provider(:useradd).stubs(:suitable?).returns false
user = Puppet::Type.type(:user).create :name => "luke", :ensure => :present, :provider => :useradd
user = Puppet::Type.type(:user).new :name => "luke", :ensure => :present, :provider => :useradd
assert_raise(Puppet::Error, "Unsuitable provider did not fail at evaluation") do
user.evaluate
end

Просмотреть файл

@ -52,7 +52,7 @@ class TestType < Test::Unit::TestCase
path = tempfile()
assert_nothing_raised() {
system("rm -f %s" % path)
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:path => path,
:ensure => "file",
:recurse => true,
@ -67,7 +67,7 @@ class TestType < Test::Unit::TestCase
}
assert_nothing_raised() {
system("rm -f %s" % path)
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
"path" => path,
"ensure" => "file",
"recurse" => true,
@ -101,7 +101,7 @@ class TestType < Test::Unit::TestCase
# currently groups are the only objects with the namevar as a property
group = nil
assert_nothing_raised {
group = Puppet::Type.type(:group).create(
group = Puppet::Type.type(:group).new(
:name => "testing"
)
}
@ -110,7 +110,7 @@ class TestType < Test::Unit::TestCase
end
def test_aliases_are_added_to_catalog
resource = Puppet::Type.type(:file).create(
resource = Puppet::Type.type(:file).new(
:name => "/path/to/some/missing/file",
:ensure => "file"
)
@ -127,7 +127,7 @@ class TestType < Test::Unit::TestCase
end
def test_aliasing_fails_without_a_catalog
resource = Puppet::Type.type(:file).create(
resource = Puppet::Type.type(:file).new(
:name => "/no/such/file",
:ensure => "file"
)
@ -145,14 +145,14 @@ class TestType < Test::Unit::TestCase
twoobj = nil
oneobj = nil
assert_nothing_raised("Could not create prereq that doesn't exist yet") {
twoobj = Puppet::Type.type(:file).create(
twoobj = Puppet::Type.type(:file).new(
:name => two,
:require => [:file, one]
)
}
assert_nothing_raised {
oneobj = Puppet::Type.type(:file).create(
oneobj = Puppet::Type.type(:file).new(
:name => one
)
}
@ -170,7 +170,7 @@ class TestType < Test::Unit::TestCase
def test_ensuredefault
user = nil
assert_nothing_raised {
user = Puppet::Type.type(:user).create(
user = Puppet::Type.type(:user).new(
:name => "pptestAA",
:check => [:uid]
)
@ -180,7 +180,7 @@ class TestType < Test::Unit::TestCase
assert(! user.property(:ensure), "User got an ensure property")
assert_nothing_raised {
user = Puppet::Type.type(:user).create(
user = Puppet::Type.type(:user).new(
:name => "pptestAB",
:comment => "Testingness"
)
@ -189,7 +189,7 @@ class TestType < Test::Unit::TestCase
assert(user.property(:ensure), "User did not add ensure property")
assert_nothing_raised {
user = Puppet::Type.type(:user).create(
user = Puppet::Type.type(:user).new(
:name => "pptestBC",
:comment => "A fake user"
)
@ -341,7 +341,7 @@ class TestType < Test::Unit::TestCase
obj = nil
path = tempfile()
assert_raise ArgumentError do
obj = Puppet::Type.type(:file).create(
obj = Puppet::Type.type(:file).new(
:name => path,
:path => path
)
@ -378,14 +378,14 @@ class TestType < Test::Unit::TestCase
echo = Puppet::Util.binary "echo"
exec1 = exec2 = nil
assert_nothing_raised do
exec1 = Puppet::Type.type(:exec).create(
exec1 = Puppet::Type.type(:exec).new(
:title => "exec1",
:command => "#{echo} funtest"
)
end
catalog.add_resource(exec1)
assert_nothing_raised do
exec2 = Puppet::Type.type(:exec).create(
exec2 = Puppet::Type.type(:exec).new(
:title => "exec2",
:command => "#{echo} funtest"
)
@ -395,14 +395,14 @@ class TestType < Test::Unit::TestCase
# Now do files, since they are. This should fail.
file1 = file2 = nil
path = tempfile()
file1 = Puppet::Type.type(:file).create(
file1 = Puppet::Type.type(:file).new(
:title => "file1",
:path => path,
:content => "yayness"
)
catalog.add_resource(file1)
file2 = Puppet::Type.type(:file).create(
file2 = Puppet::Type.type(:file).new(
:title => "file2",
:path => path,
:content => "rahness"
@ -411,7 +411,7 @@ class TestType < Test::Unit::TestCase
end
def test_tags
obj = Puppet::Type.type(:file).create(:path => tempfile())
obj = Puppet::Type.type(:file).new(:path => tempfile())
tags = [:some, :test, :tags]
@ -530,7 +530,7 @@ class TestType < Test::Unit::TestCase
# Partially test #704, but also cover the rest of the schedule management bases.
def test_schedule
schedule = Puppet::Type.type(:schedule).create(:name => "maint")
schedule = Puppet::Type.type(:schedule).new(:name => "maint")
catalog = mk_catalog(schedule)
{"maint" => true, nil => false, :fail => :fail}.each do |name, should|
@ -538,7 +538,7 @@ class TestType < Test::Unit::TestCase
if name
args[:schedule] = name
end
resource = Puppet::Type.type(:file).create(args)
resource = Puppet::Type.type(:file).new(args)
catalog.add_resource(resource)
if should == :fail
@ -566,7 +566,7 @@ class TestType < Test::Unit::TestCase
# #801 -- resources only checked in noop should be rescheduled immediately.
def test_reschedule_when_noop
Puppet::Type.type(:schedule).mkdefaultschedules
file = Puppet::Type.type(:file).create(:path => "/tmp/whatever", :mode => "755", :noop => true, :schedule => :daily, :ensure => :file)
file = Puppet::Type.type(:file).new(:path => "/tmp/whatever", :mode => "755", :noop => true, :schedule => :daily, :ensure => :file)
assert(file.noop?, "File not considered in noop")
assert(file.scheduled?, "File is not considered scheduled")

Просмотреть файл

@ -435,13 +435,13 @@ class TestCronParsedProvider < Test::Unit::TestCase
# Now make some crons that should match
matchers = [
@type.create(
@type.new(
:name => "yaycron",
:minute => [0, 30],
:command => "date",
:user => @me
),
@type.create(
@type.new(
:name => "youtest",
:command => "yaytest",
:user => you
@ -449,14 +449,14 @@ class TestCronParsedProvider < Test::Unit::TestCase
]
nonmatchers = [
@type.create(
@type.new(
:name => "footest",
:minute => [0, 30],
:hour => 1,
:command => "fooness",
:user => @me # wrong target
),
@type.create(
@type.new(
:name => "funtest2",
:command => "funtest",
:user => you # wrong target for this cron
@ -464,7 +464,7 @@ class TestCronParsedProvider < Test::Unit::TestCase
]
# Create another cron so we prefetch two of them
@type.create(:name => "testing", :minute => 30, :command => "whatever", :user => "you")
@type.new(:name => "testing", :minute => 30, :command => "whatever", :user => "you")
assert_nothing_raised("Could not prefetch cron") do
@provider.prefetch([matchers, nonmatchers].flatten.inject({}) { |crons, cron| crons[cron.name] = cron; crons })
@ -555,7 +555,7 @@ class TestCronParsedProvider < Test::Unit::TestCase
end
def test_prefetch
cron = @type.create :command => "/bin/echo yay", :name => "test", :hour => 4
cron = @type.new :command => "/bin/echo yay", :name => "test", :hour => 4
assert_nothing_raised("Could not prefetch cron") do
cron.provider.class.prefetch("test" => cron)
@ -570,7 +570,7 @@ class TestCronParsedProvider < Test::Unit::TestCase
target = @provider.target_object(@me)
# First with no env settings
resource = @type.create :command => "/bin/echo yay", :name => "test", :hour => 4
resource = @type.new :command => "/bin/echo yay", :name => "test", :hour => 4
cron = resource.provider
cron.ensure = :present

Просмотреть файл

@ -240,7 +240,7 @@ class TestGroupProvider < Test::Unit::TestCase
def test_autogen
provider = nil
group = Puppet::Type.type(:group).create(:name => nonrootgroup.name)
group = Puppet::Type.type(:group).new(:name => nonrootgroup.name)
provider = group.provider
assert(provider, "did not get provider")

Просмотреть файл

@ -14,7 +14,7 @@ class AptitudePackageProviderTest < PuppetTest::TestCase
end
def test_install
pkg = @type.create :name => 'faff',
pkg = @type.new :name => 'faff',
:provider => :aptitude,
:ensure => :present,
:source => "/tmp/faff.deb"
@ -46,7 +46,7 @@ class AptitudePackageProviderTest < PuppetTest::TestCase
end
def test_purge
pkg = @type.create :name => 'faff', :provider => :aptitude, :ensure => :purged
pkg = @type.new :name => 'faff', :provider => :aptitude, :ensure => :purged
pkg.provider.expects(
:dpkgquery

Просмотреть файл

@ -14,7 +14,7 @@ class AptrpmPackageProviderTest < PuppetTest::TestCase
end
def test_install
pkg = @type.create :name => 'faff',
pkg = @type.new :name => 'faff',
:provider => :aptrpm,
:ensure => :present,
:source => "/tmp/faff.rpm"
@ -43,7 +43,7 @@ class AptrpmPackageProviderTest < PuppetTest::TestCase
end
def test_uninstall
pkg = @type.create :name => 'faff', :provider => :aptrpm, :ensure => :absent
pkg = @type.new :name => 'faff', :provider => :aptrpm, :ensure => :absent
pkg.provider.expects(
:rpm
@ -71,7 +71,7 @@ class AptrpmPackageProviderTest < PuppetTest::TestCase
# LAK: I don't know where this test will ever return true..
def disabled_test_latest
pkg = @type.create :name => 'ssh', :provider => :aptrpm
pkg = @type.new :name => 'ssh', :provider => :aptrpm
assert(pkg, "did not create pkg")
status = pkg.provider.query

Просмотреть файл

@ -47,7 +47,7 @@ class TestParsedFile < Test::Unit::TestCase
options[:two] ||= "c"
options[:name] ||= name
resource = @type.create(options)
resource = @type.new(options)
end
def mkprovider(name = :parsed)
@ -610,7 +610,7 @@ class TestParsedFile < Test::Unit::TestCase
# Now make a resource
bill = nil
assert_nothing_raised do
bill = @type.create :name => "bill"
bill = @type.new :name => "bill"
end
assert_equal("a", bill.provider.one,
@ -627,7 +627,7 @@ class TestParsedFile < Test::Unit::TestCase
bill = nil
assert_nothing_raised do
bill = @type.create :name => "bill",
bill = @type.new :name => "bill",
:one => "a", :two => "c"
end
@ -683,7 +683,7 @@ class TestParsedFile < Test::Unit::TestCase
otarget.write("oname b d\n")
# Now make a resource that targets elsewhat.
res = @type.create(:name => "test", :one => "a", :two => "c",
res = @type.new(:name => "test", :one => "a", :two => "c",
:target => opath)
assert(res.property(:target), "Target is a parameter, not a property")

Просмотреть файл

@ -319,7 +319,7 @@ class TestProvider < Test::Unit::TestCase
def test_initialize
test = @type.provide(:test)
inst = @type.create :name => "boo"
inst = @type.new :name => "boo"
prov = nil
assert_nothing_raised("Could not init with a resource") do
prov = test.new(inst)
@ -381,7 +381,7 @@ class TestProviderFeatures < Test::Unit::TestCase
end
end
resource = @type.create(:name => "foo")
resource = @type.new(:name => "foo")
{:numbers => [:numeric], :letters => [:alpha], :both => [:numeric, :alpha],
:mixed => [], :neither => []}.each do |name, should|
should.sort! { |a,b| a.to_s <=> b.to_s }

Просмотреть файл

@ -22,7 +22,7 @@ class TestBaseServiceProvider < Test::Unit::TestCase
end
commands[c.to_sym] = path
end
service = Puppet::Type.type(:service).create(
service = Puppet::Type.type(:service).new(
:name => "yaytest", :provider => :base,
:start => "%s %s" % [commands[:touch], running],
:status => "%s -f %s" % [commands[:test], running],
@ -51,7 +51,7 @@ class TestBaseServiceProvider < Test::Unit::TestCase
# Testing #454
def test_that_failures_propagate
nope = "/no/such/command"
service = Puppet::Type.type(:service).create(
service = Puppet::Type.type(:service).new(
:name => "yaytest", :provider => :base,
:start => nope,
:status => nope,

Просмотреть файл

@ -370,7 +370,7 @@ class TestUserProvider < Test::Unit::TestCase
5.times do |i|
i += 1
name = "pptstgr%s" % i
tmpgroup = Puppet::Type.type(:group).create(
tmpgroup = Puppet::Type.type(:group).new(
:name => name,
:gid => max + i
)
@ -538,7 +538,7 @@ class TestUserProvider < Test::Unit::TestCase
def test_autogen
provider = nil
user = Puppet::Type.type(:user).create(:name => nonrootuser.name)
user = Puppet::Type.type(:user).new(:name => nonrootuser.name)
provider = user.provider
assert(provider, "did not get provider")

Просмотреть файл

@ -25,7 +25,7 @@ class UserAddProviderTest < PuppetTest::TestCase
end
def setup_user
@user = @type.create(@vals)
@user = @type.new(@vals)
@vals.each do |name, val|
next unless @user.class.validproperty?(name)
@ -230,7 +230,7 @@ class UserRootAddProviderTest < PuppetTest::TestCase
confine "not running as root" => (Process.uid == 0)
def test_password
user = Puppet::Type.type(:user).create(:name => "root", :check => [:password], :provider => :useradd)
user = Puppet::Type.type(:user).new(:name => "root", :check => [:password], :provider => :useradd)
provider = user.provider

Просмотреть файл

@ -77,7 +77,7 @@ class TestCron < Test::Unit::TestCase
args = {:command => command, :name => name}
end
assert_nothing_raised {
cron = @crontype.create(args)
cron = @crontype.new(args)
}
return cron
@ -124,7 +124,7 @@ class TestCron < Test::Unit::TestCase
name = "yaytest"
command = "date > /dev/null "
assert_nothing_raised {
cron = @crontype.create(
cron = @crontype.new(
:name => name,
:command => "date > /dev/null ",
:month => "May",
@ -224,7 +224,7 @@ class TestCron < Test::Unit::TestCase
eachprovider do |provider|
cron = nil
assert_nothing_raised {
cron = @crontype.create(
cron = @crontype.new(
:command => "/bin/date > /dev/null",
:minute => [0, 30],
:name => "crontest",
@ -250,7 +250,7 @@ class TestCron < Test::Unit::TestCase
def test_fieldremoval
cron = nil
assert_nothing_raised {
cron = @crontype.create(
cron = @crontype.new(
:command => "/bin/date > /dev/null",
:minute => [0, 30],
:name => "crontest",
@ -282,7 +282,7 @@ class TestCron < Test::Unit::TestCase
cleanup { provider.filetype = ft }
setme
cron = @crontype.create(:name => "testing",
cron = @crontype.new(:name => "testing",
:minute => [0, 30],
:command => "/bin/testing",
:user => @me
@ -424,7 +424,7 @@ class TestCron < Test::Unit::TestCase
crons = []
users = ["root", nonrootuser.name]
users.each do |user|
cron = Puppet::Type.type(:cron).create(
cron = Puppet::Type.type(:cron).new(
:name => "testcron-#{user}",
:user => user,
:command => "/bin/echo",
@ -455,7 +455,7 @@ class TestCron < Test::Unit::TestCase
def test_default_user
crontab = @crontype.provider(:crontab)
if crontab.suitable?
inst = @crontype.create(
inst = @crontype.new(
:name => "something", :command => "/some/thing",
:provider => :crontab)
assert_equal(Etc.getpwuid(Process.uid).name, inst.should(:user),
@ -465,7 +465,7 @@ class TestCron < Test::Unit::TestCase
# Now make a new cron with a user, and make sure it gets copied
# over
inst = @crontype.create(:name => "yay", :command => "/some/thing",
inst = @crontype.new(:name => "yay", :command => "/some/thing",
:user => "bin", :provider => :crontab)
assert_equal("bin", inst.should(:target),
"target did not default to user with crontab")
@ -475,10 +475,10 @@ class TestCron < Test::Unit::TestCase
# #705 - make sure extra spaces don't screw things up
def test_spaces_in_command
string = "echo multiple spaces"
cron = @crontype.create(:name => "space testing", :command => string)
cron = @crontype.new(:name => "space testing", :command => string)
assert_apply(cron)
cron = @crontype.create(:name => "space testing", :command => string)
cron = @crontype.new(:name => "space testing", :command => string)
# Now make sure that it's correctly in sync
cron.provider.class.prefetch("testing" => cron)

Просмотреть файл

@ -10,7 +10,7 @@ class TestExec < Test::Unit::TestCase
command = nil
output = nil
assert_nothing_raised {
command = Puppet::Type.type(:exec).create(
command = Puppet::Type.type(:exec).new(
:command => "/bin/echo"
)
}
@ -25,7 +25,7 @@ class TestExec < Test::Unit::TestCase
command = nil
output = nil
assert_nothing_raised {
command = Puppet::Type.type(:exec).create(
command = Puppet::Type.type(:exec).new(
:command => "/bin/echo",
:returns => val
)
@ -38,23 +38,23 @@ class TestExec < Test::Unit::TestCase
command = nil
output = nil
assert_raise(Puppet::Error) {
command = Puppet::Type.type(:exec).create(
command = Puppet::Type.type(:exec).new(
:command => "echo"
)
}
assert_nothing_raised {
command = Puppet::Type.type(:exec).create(
command = Puppet::Type.type(:exec).new(
:command => "echo",
:path => "/usr/bin:/bin:/usr/sbin:/sbin"
)
}
assert_nothing_raised {
command = Puppet::Type.type(:exec).create(
command = Puppet::Type.type(:exec).new(
:command => "/bin/echo"
)
}
assert_nothing_raised {
command = Puppet::Type.type(:exec).create(
command = Puppet::Type.type(:exec).new(
:command => "/bin/echo",
:path => "/usr/bin:/bin:/usr/sbin:/sbin"
)
@ -63,21 +63,21 @@ class TestExec < Test::Unit::TestCase
def test_nonzero_returns
assert_nothing_raised {
command = Puppet::Type.type(:exec).create(
command = Puppet::Type.type(:exec).new(
:command => "mkdir /this/directory/does/not/exist",
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
:returns => 1
)
}
assert_nothing_raised {
command = Puppet::Type.type(:exec).create(
command = Puppet::Type.type(:exec).new(
:command => "touch /etc",
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
:returns => 1
)
}
assert_nothing_raised {
command = Puppet::Type.type(:exec).create(
command = Puppet::Type.type(:exec).new(
:command => "thiscommanddoesnotexist",
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
:returns => 127
@ -92,7 +92,7 @@ class TestExec < Test::Unit::TestCase
Dir.getwd
}
assert_nothing_raised {
command = Puppet::Type.type(:exec).create(
command = Puppet::Type.type(:exec).new(
:command => "pwd",
:cwd => dir,
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
@ -109,7 +109,7 @@ class TestExec < Test::Unit::TestCase
tmpfile = tempfile()
@@tmpfiles.push tmpfile
trans = nil
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:path => tmpfile,
:content => "yay"
)
@ -119,7 +119,7 @@ class TestExec < Test::Unit::TestCase
# Now make an exec
maker = tempfile()
assert_nothing_raised {
cmd = Puppet::Type.type(:exec).create(
cmd = Puppet::Type.type(:exec).new(
:command => "touch %s" % maker,
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
:subscribe => file,
@ -145,7 +145,7 @@ class TestExec < Test::Unit::TestCase
def test_refreshonly
cmd = true
assert_nothing_raised {
cmd = Puppet::Type.type(:exec).create(
cmd = Puppet::Type.type(:exec).new(
:command => "pwd",
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
:refreshonly => true
@ -168,7 +168,7 @@ class TestExec < Test::Unit::TestCase
exec = nil
assert(! FileTest.exists?(file), "File already exists")
assert_nothing_raised {
exec = Puppet::Type.type(:exec).create(
exec = Puppet::Type.type(:exec).new(
:command => "touch %s" % file,
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
:creates => file
@ -187,13 +187,13 @@ class TestExec < Test::Unit::TestCase
sh = %x{which sh}
File.open(exe, "w") { |f| f.puts "#!#{sh}\necho yup" }
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:path => oexe,
:source => exe,
:mode => 0755
)
exec = Puppet::Type.type(:exec).create(
exec = Puppet::Type.type(:exec).new(
:command => oexe,
:require => [:file, oexe]
)
@ -210,31 +210,31 @@ class TestExec < Test::Unit::TestCase
sh = %x{which sh}
File.open(exe, "w") { |f| f.puts "#!#{sh}\necho yup" }
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:path => oexe,
:source => exe,
:mode => 755
)
basedir = File.dirname(oexe)
baseobj = Puppet::Type.type(:file).create(
baseobj = Puppet::Type.type(:file).new(
:path => basedir,
:source => exe,
:mode => 755
)
ofile = Puppet::Type.type(:file).create(
ofile = Puppet::Type.type(:file).new(
:path => exe,
:mode => 755
)
exec = Puppet::Type.type(:exec).create(
exec = Puppet::Type.type(:exec).new(
:command => oexe,
:path => ENV["PATH"],
:cwd => basedir
)
cat = Puppet::Type.type(:exec).create(
cat = Puppet::Type.type(:exec).new(
:command => "cat %s %s" % [exe, oexe],
:path => ENV["PATH"]
)
@ -270,7 +270,7 @@ class TestExec < Test::Unit::TestCase
exec = nil
assert_nothing_raised {
exec = Puppet::Type.type(:exec).create(
exec = Puppet::Type.type(:exec).new(
:command => "touch %s" % bfile,
:onlyif => "test -f %s" % afile,
:path => ENV['PATH']
@ -291,7 +291,7 @@ class TestExec < Test::Unit::TestCase
exec = nil
assert_nothing_raised {
exec = Puppet::Type.type(:exec).create(
exec = Puppet::Type.type(:exec).new(
:command => "touch %s" % bfile,
:unless => "test -f %s" % afile,
:path => ENV['PATH']
@ -339,7 +339,7 @@ class TestExec < Test::Unit::TestCase
end
exec = nil
assert_nothing_raised {
exec = Puppet::Type.type(:exec).create(args)
exec = Puppet::Type.type(:exec).new(args)
}
comp = mk_catalog("usertest", exec)
@ -374,7 +374,7 @@ class TestExec < Test::Unit::TestCase
def test_logoutput
exec = nil
assert_nothing_raised {
exec = Puppet::Type.type(:exec).create(
exec = Puppet::Type.type(:exec).new(
:title => "logoutputesting",
:path => "/usr/bin:/bin",
:command => "echo logoutput is false",
@ -405,7 +405,7 @@ class TestExec < Test::Unit::TestCase
basedir = tempfile()
path = File.join(basedir, "subfile")
assert_nothing_raised {
exec = Puppet::Type.type(:exec).create(
exec = Puppet::Type.type(:exec).new(
:title => "mkdir",
:path => "/usr/bin:/bin",
:creates => basedir,
@ -415,7 +415,7 @@ class TestExec < Test::Unit::TestCase
}
assert_nothing_raised {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:path => basedir,
:recurse => true,
:mode => "755",
@ -435,7 +435,7 @@ class TestExec < Test::Unit::TestCase
def test_falsevals
exec = nil
assert_nothing_raised do
exec = Puppet::Type.type(:exec).create(
exec = Puppet::Type.type(:exec).new(
:command => "/bin/touch yayness"
)
end
@ -455,7 +455,7 @@ class TestExec < Test::Unit::TestCase
file = tempfile()
assert_nothing_raised {
exec1 = Puppet::Type.type(:exec).create(
exec1 = Puppet::Type.type(:exec).new(
:title => "one",
:path => ENV["PATH"],
:command => "mkdir #{dir}"
@ -463,7 +463,7 @@ class TestExec < Test::Unit::TestCase
}
assert_nothing_raised("Could not create exec w/out existing cwd") {
exec2 = Puppet::Type.type(:exec).create(
exec2 = Puppet::Type.type(:exec).new(
:title => "two",
:path => ENV["PATH"],
:command => "touch #{file}",
@ -497,7 +497,7 @@ class TestExec < Test::Unit::TestCase
test = "test -f #{file}"
assert_nothing_raised {
exec = Puppet::Type.type(:exec).create(
exec = Puppet::Type.type(:exec).new(
:path => ENV["PATH"],
:command => "touch #{file}"
)
@ -534,7 +534,7 @@ class TestExec < Test::Unit::TestCase
def test_missing_checks_cause_failures
# Solaris's sh exits with 1 here instead of 127
return if Facter.value(:operatingsystem) == "Solaris"
exec = Puppet::Type.type(:exec).create(
exec = Puppet::Type.type(:exec).new(
:command => "echo true",
:path => ENV["PATH"],
:onlyif => "/bin/nosuchthingexists"
@ -626,7 +626,7 @@ and stuff"
end
def test_timeout
exec = Puppet::Type.type(:exec).create(:command => "sleep 1", :path => ENV["PATH"], :timeout => "0.2")
exec = Puppet::Type.type(:exec).new(:command => "sleep 1", :path => ENV["PATH"], :timeout => "0.2")
time = Time.now
assert_raise(Timeout::Error) {
@ -644,7 +644,7 @@ and stuff"
if Process.uid == 0
user = "nosuchuser"
assert_nothing_raised("Could not create exec with non-existent user") do
exec = Puppet::Type.type(:exec).create(
exec = Puppet::Type.type(:exec).new(
:command => "/bin/echo yay",
:user => user
)
@ -654,7 +654,7 @@ and stuff"
# Now try the group
group = "nosuchgroup"
assert_nothing_raised("Could not create exec with non-existent user") do
exec = Puppet::Type.type(:exec).create(
exec = Puppet::Type.type(:exec).new(
:command => "/bin/echo yay",
:group => group
)
@ -666,17 +666,17 @@ and stuff"
path = %w{/usr/bin /usr/sbin /sbin}
exec = nil
assert_nothing_raised("Could not use an array for the path") do
exec = Puppet::Type.type(:exec).create(:command => "echo yay",
exec = Puppet::Type.type(:exec).new(:command => "echo yay",
:path => path)
end
assert_equal(path, exec[:path], "array-based path did not match")
assert_nothing_raised("Could not use a string for the path") do
exec = Puppet::Type.type(:exec).create(:command => "echo yay",
exec = Puppet::Type.type(:exec).new(:command => "echo yay",
:path => path.join(":"))
end
assert_equal(path, exec[:path], "string-based path did not match")
assert_nothing_raised("Could not use a colon-separated strings in an array for the path") do
exec = Puppet::Type.type(:exec).create(:command => "echo yay",
exec = Puppet::Type.type(:exec).new(:command => "echo yay",
:path => ["/usr/bin", "/usr/sbin:/sbin"])
end
assert_equal(path, exec[:path], "colon-separated array path did not match")
@ -685,7 +685,7 @@ and stuff"
def test_checks_apply_to_refresh
file = tempfile()
maker = tempfile()
exec = Puppet::Type.type(:exec).create(
exec = Puppet::Type.type(:exec).new(
:title => "maker",
:command => "touch #{maker}",
:path => ENV["PATH"]
@ -724,7 +724,7 @@ and stuff"
def test_explicit_refresh
refresher = tempfile()
maker = tempfile()
exec = Puppet::Type.type(:exec).create(
exec = Puppet::Type.type(:exec).new(
:title => "maker",
:command => "touch #{maker}",
:path => ENV["PATH"]
@ -754,8 +754,8 @@ and stuff"
if Puppet.features.root?
def test_autorequire_user
user = Puppet::Type.type(:user).create(:name => "yay")
exec = Puppet::Type.type(:exec).create(:command => "/bin/echo fun", :user => "yay")
user = Puppet::Type.type(:user).new(:name => "yay")
exec = Puppet::Type.type(:exec).new(:command => "/bin/echo fun", :user => "yay")
rels = nil
assert_nothing_raised("Could not evaluate autorequire") do

Просмотреть файл

@ -13,7 +13,7 @@ class TestFile < Test::Unit::TestCase
def mkfile(hash)
file = nil
assert_nothing_raised {
file = Puppet::Type.type(:file).create(hash)
file = Puppet::Type.type(:file).new(hash)
}
return file
end
@ -104,7 +104,7 @@ class TestFile < Test::Unit::TestCase
def test_groups_fails_when_invalid
assert_raise(Puppet::Error, "did not fail when the group was empty") do
Puppet::Type.type(:file).create :path => "/some/file", :group => ""
Puppet::Type.type(:file).new :path => "/some/file", :group => ""
end
end
@ -118,7 +118,7 @@ class TestFile < Test::Unit::TestCase
file = nil
assert_nothing_raised {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:path => path,
:owner => user.name,
:ensure => "file",
@ -148,7 +148,7 @@ class TestFile < Test::Unit::TestCase
obj = nil
assert_nothing_raised {
obj = Puppet::Type.type(:file).create(
obj = Puppet::Type.type(:file).new(
:title => link,
:owner => user.name
)
@ -302,7 +302,7 @@ class TestFile < Test::Unit::TestCase
%w{a b c d}.collect { |name| tempfile() + name.to_s }.each { |path|
file =nil
assert_nothing_raised() {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:name => path,
:ensure => "file"
)
@ -321,7 +321,7 @@ class TestFile < Test::Unit::TestCase
%w{a b c d}.collect { |name| "#{basedir}/%s" % name }.each { |path|
file = nil
assert_nothing_raised() {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:name => path,
:ensure => "directory"
)
@ -365,13 +365,13 @@ class TestFile < Test::Unit::TestCase
initstorage
assert_nothing_raised {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
param => path,
:recurse => true,
:checksum => "md5"
)
}
comp = Puppet::Type.type(:component).create(
comp = Puppet::Type.type(:component).new(
:name => "component"
)
comp.push file
@ -387,7 +387,7 @@ class TestFile < Test::Unit::TestCase
end
def test_recurse?
file = Puppet::Type.type(:file).create :path => tempfile
file = Puppet::Type.type(:file).new :path => tempfile
# Make sure we default to false
assert(! file.recurse?, "Recurse defaulted to true")
@ -412,7 +412,7 @@ class TestFile < Test::Unit::TestCase
dir = nil
[true, "true", "inf", 50].each do |value|
assert_nothing_raised {
dir = Puppet::Type.type(:file).create(
dir = Puppet::Type.type(:file).new(
:path => basedir,
:recurse => value,
:check => %w{owner mode group}
@ -454,7 +454,7 @@ class TestFile < Test::Unit::TestCase
# Verify it retrieves files of type directory
assert_nothing_raised {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:name => tmpdir(),
:check => :type
)
@ -468,7 +468,7 @@ class TestFile < Test::Unit::TestCase
# And then check files
assert_nothing_raised {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:name => tempfile(),
:ensure => "file"
)
@ -503,7 +503,7 @@ class TestFile < Test::Unit::TestCase
file = nil
dirobj = nil
assert_nothing_raised("Could not make file object") {
dirobj = Puppet::Type.type(:file).create(
dirobj = Puppet::Type.type(:file).new(
:path => dir,
:recurse => true,
:check => %w{mode owner group}
@ -528,12 +528,12 @@ class TestFile < Test::Unit::TestCase
basedir = tempfile()
subfile = File.join(basedir, "subfile")
baseobj = Puppet::Type.type(:file).create(
baseobj = Puppet::Type.type(:file).new(
:name => basedir,
:ensure => "directory"
)
subobj = Puppet::Type.type(:file).create(
subobj = Puppet::Type.type(:file).new(
:name => subfile,
:ensure => "file"
)
@ -552,7 +552,7 @@ class TestFile < Test::Unit::TestCase
subpath = File.join(path, "this", "is", "a", "dir")
file = nil
assert_nothing_raised {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:name => subpath,
:ensure => "directory",
:recurse => true
@ -574,7 +574,7 @@ class TestFile < Test::Unit::TestCase
file = nil
assert_nothing_raised {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:name => dest,
:checksum => "md5",
:content => "This is some content"
@ -594,7 +594,7 @@ class TestFile < Test::Unit::TestCase
file = nil
assert_nothing_raised {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:name => dest,
:checksum => "md5",
:ensure => "file"
@ -613,7 +613,7 @@ class TestFile < Test::Unit::TestCase
file = nil
assert_nothing_raised {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:title => "fileness",
:path => path,
:content => "this is some content"
@ -629,7 +629,7 @@ class TestFile < Test::Unit::TestCase
def test_missinggroup
file = nil
assert_nothing_raised {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:path => tempfile(),
:group => "fakegroup"
)
@ -640,7 +640,7 @@ class TestFile < Test::Unit::TestCase
def test_modecreation
path = tempfile()
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:path => path,
:ensure => "file",
:mode => "0777"
@ -664,7 +664,7 @@ class TestFile < Test::Unit::TestCase
file = nil
assert_nothing_raised {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:path => path,
:ensure => "file",
:content => "some text\n",
@ -684,7 +684,7 @@ class TestFile < Test::Unit::TestCase
File.open(file, "w", 0411) { |f| f.puts "yayness" }
obj = Puppet::Type.type(:file).create(
obj = Puppet::Type.type(:file).new(
:path => file, :content => "rahness\n", :backup => ".puppet-bak"
)
catalog = mk_catalog(obj)
@ -701,7 +701,7 @@ class TestFile < Test::Unit::TestCase
name = "bucket"
bpath = tempfile()
Dir.mkdir(bpath)
bucket = Puppet::Type.type(:filebucket).create(:title => name, :path => bpath)
bucket = Puppet::Type.type(:filebucket).new(:title => name, :path => bpath)
catalog.add_resource(bucket)
obj[:backup] = name
@ -724,7 +724,7 @@ class TestFile < Test::Unit::TestCase
500.times { |i| f.puts "line %s" % i }
}
resource = Puppet::Type.type(:file).create(
resource = Puppet::Type.type(:file).new(
:title => dest, :source => source
)
@ -749,7 +749,7 @@ class TestFile < Test::Unit::TestCase
file = nil
assert_nothing_raised {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:ensure => path,
:path => link
)
@ -769,7 +769,7 @@ class TestFile < Test::Unit::TestCase
dest = File.join(dir, "another space")
File.open(source, "w") { |f| f.puts :yay }
obj = Puppet::Type.type(:file).create(
obj = Puppet::Type.type(:file).new(
:path => dest,
:source => source
)
@ -802,18 +802,18 @@ class TestFile < Test::Unit::TestCase
home = nil
ogroup = nil
assert_nothing_raised {
user = Puppet::Type.type(:user).create(
user = Puppet::Type.type(:user).new(
:name => "pptestu",
:home => file,
:gid => "pptestg"
)
home = Puppet::Type.type(:file).create(
home = Puppet::Type.type(:file).new(
:path => file,
:owner => "pptestu",
:group => "pptestg",
:ensure => "directory"
)
group = Puppet::Type.type(:group).create(
group = Puppet::Type.type(:group).new(
:name => "pptestg"
)
comp = mk_catalog(user, group, home)
@ -846,7 +846,7 @@ class TestFile < Test::Unit::TestCase
dir = tempfile()
Dir.mkdir(dir)
bucket = Puppet::Type.type(:filebucket).create :name => "main"
bucket = Puppet::Type.type(:filebucket).new :name => "main"
File.symlink(dir, link)
File.open(file, "w") { |f| f.puts "" }
assert_equal(dir, File.readlink(link))
@ -897,7 +897,7 @@ class TestFile < Test::Unit::TestCase
:link => proc { File.symlink(linkdest, path) }
}
bucket = Puppet::Type.type(:filebucket).create :name => "main", :path => tempfile()
bucket = Puppet::Type.type(:filebucket).new :name => "main", :path => tempfile()
obj = Puppet::Type.newfile :path => path, :force => true,
:links => :manage
@ -1040,7 +1040,7 @@ class TestFile < Test::Unit::TestCase
assert_equal("main", file.bucket, "file's bucket was not set")
# And then an existing bucket
obj = Puppet::Type.type(:filebucket).create :name => "testing"
obj = Puppet::Type.type(:filebucket).new :name => "testing"
catalog.add_resource(obj)
bucket = obj.bucket

Просмотреть файл

@ -24,7 +24,7 @@ class TestFileTarget < Test::Unit::TestCase
file = nil
assert_nothing_raised {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:title => "somethingelse",
:ensure => path,
:path => link
@ -52,7 +52,7 @@ class TestFileTarget < Test::Unit::TestCase
system("mkdir -p %s" % subdir)
system("touch %s" % file)
link = Puppet::Type.type(:file).create(
link = Puppet::Type.type(:file).new(
:ensure => source,
:path => path,
:recurse => true
@ -97,7 +97,7 @@ class TestFileTarget < Test::Unit::TestCase
link = nil
assert_nothing_raised {
link = Puppet::Type.type(:file).create(
link = Puppet::Type.type(:file).new(
:ensure => source,
:path => dest,
:recurse => true
@ -132,7 +132,7 @@ class TestFileTarget < Test::Unit::TestCase
link = nil
assert_nothing_raised {
link = Puppet::Type.type(:file).create(
link = Puppet::Type.type(:file).new(
:path => dest,
:ensure => "source"
)
@ -149,12 +149,12 @@ class TestFileTarget < Test::Unit::TestCase
dest = tempfile()
resources = []
resources << Puppet::Type.type(:exec).create(
resources << Puppet::Type.type(:exec).new(
:command => "mkdir %s; touch %s/file" % [source, source],
:title => "yay",
:path => ENV["PATH"]
)
resources << Puppet::Type.type(:file).create(
resources << Puppet::Type.type(:file).new(
:ensure => source,
:path => dest,
:recurse => true,
@ -203,7 +203,7 @@ class TestFileTarget < Test::Unit::TestCase
file = nil
assert_nothing_raised {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:ensure => path,
:path => link,
:backup => false
@ -234,7 +234,7 @@ class TestFileTarget < Test::Unit::TestCase
File.open(file, "w") { |f| f.puts "yayness" }
File.symlink(file, link)
obj = Puppet::Type.type(:file).create(
obj = Puppet::Type.type(:file).new(
:path => link,
:ensure => "file"
)
@ -265,7 +265,7 @@ class TestFileTarget < Test::Unit::TestCase
File.open(sourcefile, "w") { |f| f.puts "source" }
File.symlink(file, link)
obj = Puppet::Type.type(:file).create(
obj = Puppet::Type.type(:file).new(
:path => dirs["target"],
:ensure => :file,
:source => dirs["source"],
@ -295,7 +295,7 @@ class TestFileTarget < Test::Unit::TestCase
File.open(dest, "w") { |f| f.puts "boo" }
File.open(otherdest, "w") { |f| f.puts "yay" }
obj = Puppet::Type.type(:file).create(
obj = Puppet::Type.type(:file).new(
:path => link,
:ensure => otherdest
)

Просмотреть файл

@ -15,7 +15,7 @@ class TestFileBucket < Test::Unit::TestCase
def mkfile(hash)
file = nil
assert_nothing_raised {
file = Puppet::Type.type(:file).create(hash)
file = Puppet::Type.type(:file).new(hash)
}
return file
end
@ -23,7 +23,7 @@ class TestFileBucket < Test::Unit::TestCase
def mkbucket(name,path)
bucket = nil
assert_nothing_raised {
bucket = Puppet::Type.type(:filebucket).create(
bucket = Puppet::Type.type(:filebucket).new(
:name => name,
:path => path
)

Просмотреть файл

@ -69,7 +69,7 @@ class TestFileIgnoreSources < Test::Unit::TestCase
#makes Puppet file Object
assert_nothing_raised {
tofile = Puppet::Type.type(:file).create(
tofile = Puppet::Type.type(:file).new(
:name => topath,
:source => frompath,
:recurse => true,
@ -133,7 +133,7 @@ class TestFileIgnoreSources < Test::Unit::TestCase
#makes Puppet file Object
assert_nothing_raised {
tofile = Puppet::Type.type(:file).create(
tofile = Puppet::Type.type(:file).new(
:name => topath,
:source => frompath,
:recurse => true,
@ -205,7 +205,7 @@ class TestFileIgnoreSources < Test::Unit::TestCase
#makes Puppet file Object
assert_nothing_raised {
tofile = Puppet::Type.type(:file).create(
tofile = Puppet::Type.type(:file).new(
:name => topath,
:source => frompath,
:recurse => true,

Просмотреть файл

@ -59,7 +59,7 @@ class TestFileSources < Test::Unit::TestCase
tofile = nil
trans = nil
tofile = Puppet::Type.type(:file).create(
tofile = Puppet::Type.type(:file).new(
:path => todir,
:recurse => true,
:backup => false,
@ -192,7 +192,7 @@ class TestFileSources < Test::Unit::TestCase
File.open(file1, "w") { |f| f.puts "yay" }
rootobj = nil
assert_nothing_raised {
rootobj = Puppet::Type.type(:file).create(
rootobj = Puppet::Type.type(:file).new(
:name => basedir,
:recurse => true,
:check => %w{type owner},
@ -264,7 +264,7 @@ class TestFileSources < Test::Unit::TestCase
sleep(1)
name = File.join(tmpdir(), "nosourcefile")
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:source => "puppet://localhost/noexist/file",
:name => name
)
@ -291,7 +291,7 @@ class TestFileSources < Test::Unit::TestCase
# Now the files should be exactly the same, so we should not see attempts
# at copying
assert_nothing_raised {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:path => to,
:source => from
)
@ -317,7 +317,7 @@ class TestFileSources < Test::Unit::TestCase
file = nil
assert_nothing_raised {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:name => to,
:source => files
)
@ -343,7 +343,7 @@ class TestFileSources < Test::Unit::TestCase
file = nil
assert_nothing_raised {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:name => dest,
:source => source
)
@ -364,7 +364,7 @@ class TestFileSources < Test::Unit::TestCase
file = nil
assert_nothing_raised {
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:name => dest,
:ensure => "file",
:source => source
@ -387,7 +387,7 @@ class TestFileSources < Test::Unit::TestCase
File.open(source, "w") { |f| f.puts "yay" }
File.symlink(source, link)
file = Puppet::Type.type(:file).create(:name => dest, :source => link)
file = Puppet::Type.type(:file).new(:name => dest, :source => link)
catalog = mk_catalog(file)

Просмотреть файл

@ -47,7 +47,7 @@ class TestGroup < Test::Unit::TestCase
group = nil
hash[:name] = name
assert_nothing_raised {
group = Puppet::Type.type(:group).create(hash)
group = Puppet::Type.type(:group).new(hash)
}
return group
@ -115,7 +115,7 @@ class TestGroup < Test::Unit::TestCase
gobj = nil
comp = nil
assert_nothing_raised {
gobj = Puppet::Type.type(:group).create(
gobj = Puppet::Type.type(:group).new(
:name => group,
:check => [:gid]
)
@ -139,7 +139,7 @@ class TestGroup < Test::Unit::TestCase
name = "pptestgr"
assert_nothing_raised {
gobj = Puppet::Type.type(:group).create(
gobj = Puppet::Type.type(:group).new(
:name => name,
:gid => 123
)

Просмотреть файл

@ -43,7 +43,7 @@ class TestHost < Test::Unit::TestCase
host = nil
assert_nothing_raised {
host = Puppet::Type.type(:host).create(
host = Puppet::Type.type(:host).new(
:name => "fakehost%s" % @hcount,
:ip => "192.168.27.%s" % @hcount,
:alias => "alias%s" % @hcount,
@ -73,7 +73,7 @@ class TestHost < Test::Unit::TestCase
end
assert_nothing_raised {
host = Puppet::Type.type(:host).create(
host = Puppet::Type.type(:host).new(
:name => "culain",
:ip => "192.168.0.3"
)

Просмотреть файл

@ -33,7 +33,7 @@ class TestMailAlias < Test::Unit::TestCase
# This isn't much of a test, but then, it's not much of a type.
def test_recipient_arrays
resource = @type.create(:name => "luke", :recipient => "yay", :target => tempfile)
resource = @type.new(:name => "luke", :recipient => "yay", :target => tempfile)
values = nil
assert_nothing_raised("Could not retrieve mailalias") do
values = resource.retrieve.inject({}) { |hash, a| hash[a[0].name] = a[1]; hash }

Просмотреть файл

@ -40,7 +40,7 @@ require 'puppettest'
# @pcount = 1
# end
# assert_nothing_raised {
# port = Puppet::Type.type(:port).create(
# port = Puppet::Type.type(:port).new(
# :name => "puppet%s" % @pcount,
# :number => "813%s" % @pcount,
# :protocols => "tcp",

Просмотреть файл

@ -65,7 +65,7 @@ class TestResources < Test::Unit::TestCase
purger = nil
assert_nothing_raised do
purger = @type.create :name => "purgetest", :noop => true, :loglevel => :warning
purger = @type.new :name => "purgetest", :noop => true, :loglevel => :warning
end
assert(purger, "did not get purger manager")
add_purge_lister()
@ -126,18 +126,18 @@ class TestResources < Test::Unit::TestCase
# Part of #408.
def test_check
# First check a non-user
res = Puppet::Type.type(:resources).create :name => :package
res = Puppet::Type.type(:resources).new :name => :package
assert_nil(res[:unless_system_user], "got bad default for package")
assert_nothing_raised {
assert(res.check("A String"), "String failed check")
assert(res.check(Puppet::Type.type(:file).create(:path => tempfile())), "File failed check")
assert(res.check(Puppet::Type.type(:user).create(:name => "yayness")), "User failed check in package")
assert(res.check(Puppet::Type.type(:file).new(:path => tempfile())), "File failed check")
assert(res.check(Puppet::Type.type(:user).new(:name => "yayness")), "User failed check in package")
}
# Now create a user manager
res = Puppet::Type.type(:resources).create :name => :user
res = Puppet::Type.type(:resources).new :name => :user
# Make sure the default is 500
assert_equal(500, res[:unless_system_user], "got bad default")
@ -175,7 +175,7 @@ class TestResources < Test::Unit::TestCase
# The other half of #408.
def test_check_is_called
res = Puppet::Type.type(:resources).create :name => :user, :purge => true
res = Puppet::Type.type(:resources).new :name => :user, :purge => true
list = nil
assert_nothing_raised { list = res.generate }

Просмотреть файл

@ -10,7 +10,7 @@ class TestServiceType < Test::Unit::TestCase
# #199
def test_no_refresh_when_starting
service = Puppet::Type.type(:service).create :name => "hopefully_this_isnt_in_the_process_table",
service = Puppet::Type.type(:service).new :name => "hopefully_this_isnt_in_the_process_table",
:ensure => :running, :provider => :base
assert_equal :running, service.instance_eval('@parameters[:ensure]').should
@ -25,7 +25,7 @@ class TestServiceType < Test::Unit::TestCase
end
def test_refresh_normally
service = Puppet::Type.type(:service).create :name => "testing",
service = Puppet::Type.type(:service).new :name => "testing",
:ensure => :running, :provider => :base, :status => "cat /dev/null"
service.provider.expects(:restart)

Просмотреть файл

@ -48,7 +48,7 @@ class TestSSHKey < Test::Unit::TestCase
@catalog ||= mk_catalog
key = @sshkeytype.create(
key = @sshkeytype.new(
:name => "host%s.madstop.com" % @kcount,
:key => "%sAAAAB3NzaC1kc3MAAACBAMnhSiku76y3EGkNCDsUlvpO8tRgS9wL4Eh54WZfQ2lkxqfd2uT/RTT9igJYDtm/+UHuBRdNGpJYW1Nw2i2JUQgQEEuitx4QKALJrBotejGOAWxxVk6xsh9xA0OW8Q3ZfuX2DDitfeC8ZTCl4xodUMD8feLtP+zEf8hxaNamLlt/AAAAFQDYJyf3vMCWRLjTWnlxLtOyj/bFpwAAAIEAmRxxXb4jjbbui9GYlZAHK00689DZuX0EabHNTl2yGO5KKxGC6Esm7AtjBd+onfu4Rduxut3jdI8GyQCIW8WypwpJofCIyDbTUY4ql0AQUr3JpyVytpnMijlEyr41FfIb4tnDqnRWEsh2H7N7peW+8DWZHDFnYopYZJ9Yu4/jHRYAAACAERG50e6aRRb43biDr7Ab9NUCgM9bC0SQscI/xdlFjac0B/kSWJYTGVARWBDWug705hTnlitY9cLC5Ey/t/OYOjylTavTEfd/bh/8FkAYO+pWdW3hx6p97TBffK0b6nrc6OORT2uKySbbKOn0681nNQh4a6ueR3JRppNkRPnTk5c=" % @kcount,
:type => "ssh-dss",
@ -91,7 +91,7 @@ class TestSSHKey < Test::Unit::TestCase
name = key.name
key = nil
key = @sshkeytype.create :name => name, :target => file, :provider => :parsed
key = @sshkeytype.new :name => name, :target => file, :provider => :parsed
key.retrieve
assert(key.provider.exists?, "key thinks it does not exist")

Просмотреть файл

@ -64,7 +64,7 @@ class TestUser < Test::Unit::TestCase
def mkuser(name)
user = nil
assert_nothing_raised {
user = Puppet::Type.type(:user).create(
user = Puppet::Type.type(:user).new(
:name => name,
:comment => "Puppet Testing User",
:gid => Puppet::Util::SUIDManager.gid,
@ -314,7 +314,7 @@ class TestUser < Test::Unit::TestCase
def test_groups_list_must_not_contain_commas
assert_raise(Puppet::Error) do
Puppet::Type.type(:user).create :name => "luke", :groups => "root,adm"
Puppet::Type.type(:user).new :name => "luke", :groups => "root,adm"
end
end
@ -326,21 +326,21 @@ class TestUser < Test::Unit::TestCase
home = nil
ogroup = nil
assert_nothing_raised {
user = Puppet::Type.type(:user).create(
user = Puppet::Type.type(:user).new(
:name => "pptestu",
:home => file,
:gid => "pptestg",
:groups => "yayness"
)
home = Puppet::Type.type(:file).create(
home = Puppet::Type.type(:file).new(
:path => file,
:owner => "pptestu",
:ensure => "directory"
)
group = Puppet::Type.type(:group).create(
group = Puppet::Type.type(:group).new(
:name => "pptestg"
)
ogroup = Puppet::Type.type(:group).create(
ogroup = Puppet::Type.type(:group).new(
:name => "yayness"
)
comp = mk_catalog(user, group, home, ogroup)
@ -404,7 +404,7 @@ class TestUser < Test::Unit::TestCase
# Testing #455
def test_autorequire_with_no_group_should
user = Puppet::Type.type(:user).create(:name => "yaytest", :check => :all)
user = Puppet::Type.type(:user).new(:name => "yaytest", :check => :all)
catalog = mk_catalog(user)
assert_nothing_raised do
@ -424,7 +424,7 @@ class TestUser < Test::Unit::TestCase
# Make sure the 'managehome' param can only be set when the provider
# has that feature. Uses a patch from #432.
def test_managehome
user = Puppet::Type.type(:user).create(:name => "yaytest", :check => :all)
user = Puppet::Type.type(:user).new(:name => "yaytest", :check => :all)
prov = user.provider

Просмотреть файл

@ -80,7 +80,7 @@ class TestYumRepo < Test::Unit::TestCase
def make_repo(name, hash={})
hash[:name] = name
Puppet::Type.type(:yumrepo).create(hash)
Puppet::Type.type(:yumrepo).new(hash)
end
def all_sections(inifile)

Просмотреть файл

@ -21,7 +21,7 @@ class TestZone < PuppetTest::TestCase
File.chmod(0700, base)
root = File.join(base, "zonebase")
assert_nothing_raised {
zone = Puppet::Type.type(:zone).create(
zone = Puppet::Type.type(:zone).new(
:name => name,
:path => root,
:ensure => "configured" # don't want to install zones automatically
@ -177,7 +177,7 @@ class TestZoneAsRoot < TestZone
@@zones.each do |zone|
next unless current.include? zone
obj = Puppet::Type.type(:zone).create(:name => zone)
obj = Puppet::Type.type(:zone).new(:name => zone)
obj[:ensure] = :absent
assert_apply(obj)
end

Просмотреть файл

@ -129,7 +129,7 @@ class TestLog < Test::Unit::TestCase
# Verify that the error and source are always strings
def test_argsAreStrings
msg = nil
file = Puppet::Type.type(:file).create(
file = Puppet::Type.type(:file).new(
:path => tempfile(),
:check => %w{owner group}
)

Просмотреть файл

@ -12,7 +12,7 @@ class TestStorage < Test::Unit::TestCase
path = tempfile()
File.open(path, "w") { |f| f.puts :yayness }
f = Puppet::Type.type(:file).create(
f = Puppet::Type.type(:file).new(
:name => path,
:check => %w{checksum type}
)
@ -101,7 +101,7 @@ class TestStorage < Test::Unit::TestCase
def test_caching
hash = nil
one = Puppet::Type.type(:exec).create :title => "/bin/echo one"
one = Puppet::Type.type(:exec).new :title => "/bin/echo one"
[one, :yayness].each do |object|
assert_nothing_raised do
hash = Puppet::Util::Storage.cache(object)