summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-07-11 20:58:25 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-07-11 20:58:25 +0000
commit8063ab1f573e7d4404fddca62a4134b2254f8d1d (patch)
treed0f3137b7839f2450b3ab1ca22b392053c75c6b8
parent1ab45947dab40a99c331a5dc550dc00f54dc3180 (diff)
downloadpuppet-8063ab1f573e7d4404fddca62a4134b2254f8d1d.tar.gz
puppet-8063ab1f573e7d4404fddca62a4134b2254f8d1d.tar.xz
puppet-8063ab1f573e7d4404fddca62a4134b2254f8d1d.zip
Fixing filebucket server so that paths are not added multiple times
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1392 980ebf18-57e1-0310-9a29-db15c13687c0
-rwxr-xr-xlib/puppet/server/filebucket.rb2
-rw-r--r--test/server/bucket.rb27
2 files changed, 25 insertions, 4 deletions
diff --git a/lib/puppet/server/filebucket.rb b/lib/puppet/server/filebucket.rb
index d07fc93af..3fd4a8f5f 100755
--- a/lib/puppet/server/filebucket.rb
+++ b/lib/puppet/server/filebucket.rb
@@ -109,7 +109,7 @@ class Server
addpath = false
if FileTest.exists?(pathpath)
File.open(pathpath) { |of|
- paths = of.readlines
+ paths = of.readlines.collect { |l| l.chomp }
}
# unless our path is already there...
diff --git a/test/server/bucket.rb b/test/server/bucket.rb
index 8171b2740..af2fd0865 100644
--- a/test/server/bucket.rb
+++ b/test/server/bucket.rb
@@ -140,9 +140,7 @@ class TestBucket < Test::Unit::TestCase
def setup
super
- @bucket = File.join(Puppet[:confdir], "buckettesting")
-
- @@tmpfiles << @bucket
+ @bucket = tempfile()
end
#def teardown
@@ -240,6 +238,29 @@ class TestBucket < Test::Unit::TestCase
end
Process.kill("TERM", pid)
end
+
+ def test_no_path_duplicates
+ bucket = nil
+ assert_nothing_raised {
+ bucket = Puppet::Server::FileBucket.new(
+ :Bucket => @bucket
+ )
+ }
+
+ sum = nil
+ assert_nothing_raised {
+ sum = bucket.addfile("yayness", "/my/file")
+ }
+ assert_nothing_raised {
+ bucket.addfile("yayness", "/my/file")
+ }
+
+ pathfile = File.join(bucket.path, sum, "paths")
+
+ assert(FileTest.exists?(pathfile), "No path file at %s" % pathfile)
+
+ assert_equal("/my/file\n", File.read(pathfile))
+ end
end
# $Id$