On Tue, Jun 2, 2009 at 8:15 PM, Luke Kanies<[email protected]> wrote:
>
> Can you provide some comments in here on what these helpers are used
> for? It's a lot of scaffolding code, and it'd be nice if we could
> find a way for it not to be necessary, because it makes the tests
> harder to read in place.
Well there are are a few things that get done at the beginning and end
of each integration test, such as deleting users created by a test,
creating users for a test, etc. It's these tasks that have gone into
the scaffolding code. I've reduced it by quite a bit, and I've renamed
some of the method names to make them more self explanatory. See my
new code below. I'd appreciate your perspective. If you think they
still need comments, I'll add them in. I really like to keep comments
out of my code as far as possible though.
diff --git a/spec/lib/windowstest.rb b/spec/lib/windowstest.rb
new file mode 100644
index 0000000..d160fda
--- /dev/null
+++ b/spec/lib/windowstest.rb
@@ -0,0 +1,60 @@
+require File.dirname(__FILE__) + '/../../lib/puppet/util/windows_system.rb'
+
+module WindowsTest
+ include Puppet::Util::Windows
+
+ def group(name)
+ Group.new(name)
+ end
+
+ def user(name)
+ User.new(name)
+ end
+
+ def create_test_groups(groupnames)
+ list = groupnames.collect do |name|
+ group = Puppet::Util::Windows::Group.create(name)
+ delete_group_later name
+ group
+ end
+
+ return list[0] if list.length == 1
+ return list
+ end
+
+ def create_test_user(username, password)
+ user = Puppet::Util::Windows::User.create(username, password)
+ @users_to_delete << username
+ return user
+ end
+
+ def create_test_users(*usernames)
+ password = "qwertyuiop"
+
+ list = usernames.flatten.collect do |name|
+ create_test_user(name, password)
+ end
+
+ return list[0] if list.length == 1
+ return list
+ end
+
+ def delete_test_users
+ @users_to_delete.each {|name|
Puppet::Util::Windows::User.delete(name) }
+ @users_to_delete = []
+ end
+
+ def delete_test_groups
+ @groups_to_delete.each {|name|
Puppet::Util::Windows::Group.delete(name) }
+ @groups_to_delete = []
+ end
+
+ def delete_group_later(groupname)
+ @groups_to_delete << groupname
+ end
+
+ def delete_user_later(username)
+ @users_to_delete << username
+ end
+end
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---