yore 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/test/S3_test.rb ADDED
@@ -0,0 +1,141 @@
1
+ require 'rubygems'
2
+ gem 'RequirePaths'; require 'require_paths'
3
+ require_paths '../../..','../lib'
4
+ require 'ihl_ruby/misc_utils'
5
+ require 'ihl_ruby/shell_extras'
6
+ require 'yore/yore_core'
7
+ require 'test/unit'
8
+ gem 'Shoulda'; require 'shoulda'
9
+ require 'fileutils'
10
+
11
+ def ensure_clean_bucket(aName)
12
+ `s3cmd createbucket #{aName}`
13
+ `s3cmd deleteall #{aName}`
14
+ end
15
+
16
+ # finwa example : yore backup /var/www/joomla/deploy-system/finwa_yore.xml >/dev/null 2>&1
17
+
18
+ class S3Test < Test::Unit::TestCase
19
+
20
+ def setup
21
+ @yore = YoreCore::Yore.new
22
+ end
23
+
24
+ should "upload and download files intact" do
25
+ bucket = 'yore_test'
26
+ ensure_clean_bucket(bucket)
27
+ @yore.configure({
28
+ :bucket => bucket
29
+ })
30
+ content = 'this is my test content'
31
+ temp_dir = MiscUtils.make_temp_dir()
32
+ temp_file = MiscUtils.make_temp_file(nil, temp_dir, content)
33
+ puts @yore.upload(temp_file)
34
+ orig_file = temp_file+'.orig'
35
+ File.rename(temp_file, orig_file)
36
+ puts @yore.download(temp_file)
37
+ down_file_content = MiscUtils.string_from_file(temp_file)
38
+ assert_equal content, down_file_content
39
+ end
40
+
41
+ should "backup and restore multiple directories of file" do
42
+ # create a temp dir
43
+ temp_dir = MiscUtils::make_temp_dir('yore_test')
44
+ # create source and dest subfolders
45
+ source_dir = File.expand_path('source',temp_dir)
46
+ source1 = File.join(source_dir,'source1')
47
+ source2 = File.join(source_dir,'source2')
48
+ dest_dir = File.expand_path('dest',temp_dir)
49
+ bucket = 'yore_test'
50
+
51
+ FileUtils.mkdir_p([source1,source2,dest_dir])
52
+ # create some dirs and files in source
53
+ ['a','a/1','b','c'].each {|p| FileUtils.mkdir_p(File.expand_path(p,source1))}
54
+ %w(a/blah.txt a/1/blahblah.txt b/apples.txt c/carrots.txt).each do |f|
55
+ MiscUtils::make_temp_file(f,source1)
56
+ end
57
+ ['w','x/1','y/2','z'].each {|p| FileUtils.mkdir_p(File.expand_path(p,source2))}
58
+ %w(w/zonk.txt x/1/eggs.txt y/2/bloop.txt z/zax.txt).each do |f|
59
+ MiscUtils::make_temp_file(f,source2)
60
+ end
61
+
62
+
63
+ ensure_clean_bucket(bucket)
64
+
65
+ # create job file
66
+ job_template = <<-EOF
67
+ <?xml version="1.0" encoding="UTF-8"?>
68
+ <Yore>
69
+ <SimpleItems>
70
+ <Item Name="crypto_iv">3A63775C1E3F291B0925578165EB917E</Item>
71
+ <Item Name="crypto_key">07692FC8656F04AE5518B80D38681E038A3C12050DF6CC97CEEC33D800D5E2FE</Item>
72
+ <Item Name="prefix">backup</Item>
73
+ <Item Name="log_level">INFO</Item>
74
+ <Item Name="bucket">${BUCKET}</Item>
75
+ </SimpleItems>
76
+ <Sources>
77
+ <Source Type="File" BasePath="${SOURCE_DIR}">
78
+ <IncludePath>source1</IncludePath>
79
+ <IncludePath>source2</IncludePath>
80
+ </Source>
81
+ </Sources>
82
+ </Yore>
83
+ EOF
84
+
85
+ job_content = StringUtils::render_template(job_template,{
86
+ 'SOURCE_DIR' => source_dir,
87
+ 'BUCKET' => bucket
88
+ })
89
+ MiscUtils::string_to_file(job_content,job_file = MiscUtils::temp_file)
90
+
91
+ # call yore script with ruby from the command line, then download result and check contents
92
+ begin
93
+ _xmlRoot = XmlUtils.get_xml_root(job_content)
94
+ cmd_options = {:config => job_file}
95
+ @yore_upload = YoreCore::Yore::launch(_xmlRoot,cmd_options,{:basepath => File.dirname(File.expand_path(job_file))})
96
+ @yore_upload.backup([job_file],cmd_options)
97
+ rescue ::StandardError => e
98
+ flunk e.inspect
99
+ end
100
+
101
+ #puts result
102
+ yore = YoreCore::Yore.new()
103
+ yore.configure({
104
+ :bucket => bucket
105
+ })
106
+
107
+ retrieved_fname = File.expand_path(yore.encode_file_name(), dest_dir)
108
+ collection_fname = MiscUtils::temp_file
109
+
110
+ puts yore.download(retrieved_fname)
111
+ puts yore.unpack(retrieved_fname,collection_fname)
112
+
113
+ filelist = MiscUtils::recursive_file_list(source_dir,false)
114
+
115
+ # check contains filelist files
116
+ cmd = "tar --list --file=#{collection_fname}"
117
+ filelist_out = yore.shell(cmd)
118
+ filelist_out = filelist_out.split("\n").sort
119
+ assert_equal filelist, filelist_out
120
+ end
121
+
122
+ should "handle test_file_b" do
123
+ aController = YoreCore::Yore.new # main program object
124
+ srcdir = '/tmp/yoretest'
125
+ FileUtils.rm_rf srcdir+'/*'
126
+ FileUtils.mkdir_p srcdir
127
+ ['a','a/1','b','c'].each {|p| FileUtils.mkdir_p(File.expand_path(p,srcdir))}
128
+ %w(a/blah.txt a/1/blahblah.txt b/apples.txt c/carrots.txt).each do |f|
129
+ MiscUtils::make_temp_file(f,srcdir)
130
+ end
131
+
132
+ job = File.expand_path('../../test/test_job_b.xml',THIS_DIR)
133
+ aController.configure(job)
134
+ aController.backup([job])
135
+ end
136
+
137
+ should "provide configurable criteria for keeping old files"
138
+
139
+ should "clean a folder full of files, removing files that don't match configurable criteria for keeping old files"
140
+
141
+ end
@@ -0,0 +1,182 @@
1
+ require 'rubygems'
2
+ gem 'RequirePaths'; require 'require_paths'
3
+ require_paths '../../..','../lib'
4
+
5
+ require 'ihl_ruby/misc_utils'
6
+ require 'ihl_ruby/config'
7
+ require 'ihl_ruby/shell_extras'
8
+ require 'yore/yore_core'
9
+ require 'test/unit'
10
+ gem 'Shoulda'; require 'shoulda'
11
+ require 'fileutils'
12
+
13
+
14
+ class LoadsaveYoreTest < Test::Unit::TestCase
15
+
16
+ def setup
17
+ #@yore = YoreCore::Yore.new
18
+ end
19
+
20
+ should "save a spree applications data to a file and then load it into a different project" do
21
+ require "mysql"
22
+ cred = Credentials.new()
23
+ db_details = {
24
+ :username => cred[:mysql_username],
25
+ :password => cred[:mysql_password]
26
+ }
27
+
28
+ def create_spree_db(aDbDetails)
29
+ assert mysql = Mysql.new("localhost",aDbDetails[:username],aDbDetails[:password])
30
+ mysql.query("DROP DATABASE IF EXISTS #{aDbDetails[:database]}")
31
+ mysql.query("CREATE DATABASE #{aDbDetails[:database]}")
32
+ #assert mysql.query("GRANT ALL ON #{aName}.* TO rubyuser@localhost IDENTIFIED by 'ruby'")
33
+ mysql.select_db(aDbDetails[:database])
34
+ mysql.query("
35
+ CREATE TABLE products (
36
+ id int(11) NOT NULL AUTO_INCREMENT,
37
+ name varchar(30),
38
+ description varchar(50),
39
+ PRIMARY KEY (id)
40
+ )
41
+ ")
42
+ mysql.query("INSERT INTO products (name,description) VALUES('spoon', 'golden spoon -#{aDbDetails[:database]}')")
43
+ mysql.query("INSERT INTO products (name,description) VALUES('fork', 'silver fork -#{aDbDetails[:database]}')")
44
+ mysql.query("
45
+ CREATE TABLE customers (
46
+ id int(11) NOT NULL AUTO_INCREMENT,
47
+ name varchar(30),
48
+ address varchar(50),
49
+ PRIMARY KEY (id)
50
+ )
51
+ ")
52
+ mysql.query("INSERT INTO customers (name,address) VALUES('fred', '1 some st -#{aDbDetails[:database]}')")
53
+ mysql.query("INSERT INTO customers (name,address) VALUES('mary', '2 another rd -#{aDbDetails[:database]}')")
54
+ return mysql
55
+ end
56
+
57
+ #users = [{:name => 'Bob', :permissions => ['Read']},
58
+ # {:name => 'Alice', :permissions => ['Read', 'Write']}]
59
+ #
60
+ ## Serialize
61
+ #open('users', 'w') { |f| YAML.dump(users, f) }
62
+ #
63
+ ## And deserialize
64
+ #users2 = open("users") { |f| YAML.load(f) }
65
+ ## => [{:permissions=>["Read"], :name=>"Bob"},
66
+ ## {:permissions=>["Read", "Write"], :name=>"Alice"}]
67
+
68
+ def hash_from_yaml_file(aFile)
69
+ return YAML::load(File.open(aFile)) rescue nil
70
+ end
71
+
72
+ def yaml_file_from_hash(aName,aHash)
73
+ open(aName, 'w') { |f| YAML.dump(aHash, f) }
74
+ end
75
+
76
+ RAND_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
77
+ def random_string(aLength)
78
+ rand_max = RAND_CHARS.size
79
+ ret = ""
80
+ aLength.times{ ret << RAND_CHARS[rand(rand_max)] }
81
+ ret
82
+ end
83
+
84
+ def random_filename(aPrefix=nil)
85
+ aPrefix.to_s+random_string(8)+'.'+random_string(3)
86
+ end
87
+
88
+ def create_random_file(aPath,aLength,aName=nil)
89
+ aName ||= random_filename()
90
+ path = File.join(aPath,aName)
91
+ MiscUtils.string_to_file(random_string(aLength),path)
92
+ end
93
+
94
+ # eg
95
+ def create_spree_folder(aParentDir,aFolderName,aDatabaseParams)
96
+ path = File.expand_path(aFolderName,aParentDir)
97
+ FileUtils.mkdir_p(path)
98
+ FileUtils.mkdir_p(File.join(path,'config'))
99
+ FileUtils.mkdir_p(File.join(path,'kind'))
100
+ FileUtils.mkdir_p(File.join(path,'public/assets/products'))
101
+ # create database yml file
102
+ dbs = {
103
+ 'bogus' => {
104
+ 'adapter' => 'mysql',
105
+ 'database' => 'sdsdsad',
106
+ 'username' => 'asdsadasd',
107
+ 'password' => 'dfdsgdfg'
108
+ }
109
+ }
110
+ params = {'adapter' => 'mysql'}
111
+ aDatabaseParams.values.first.each {|k,v| params[k.to_s] = v}
112
+ dbs[aDatabaseParams.keys.first.to_s] = params
113
+ yaml_file_from_hash(File.join(path,'config/database.yml'),dbs)
114
+
115
+ 3.times { create_random_file(File.join(path,'kind'),1+rand(100),random_filename(aFolderName+'_')) }
116
+ 3.times { create_random_file(File.join(path,'public'),1+rand(100),random_filename(aFolderName+'_')) }
117
+ 3.times { create_random_file(File.join(path,'public/assets'),1+rand(100),random_filename(aFolderName+'_')) }
118
+ 3.times { create_random_file(File.join(path,'public/assets/products'),1+rand(100),random_filename(aFolderName+'_')) }
119
+ return path
120
+ end
121
+
122
+ def filelist_with_sizes(aPath)
123
+ result = MiscUtils.recursive_file_list(aPath,true)
124
+ result.map! do |f|
125
+ shortf = MiscUtils.path_debase(f,aPath)
126
+ shortf + "|#{File.size?(f).to_s}"
127
+ end
128
+ result
129
+ end
130
+
131
+ tempdir = MiscUtils.make_temp_dir("yore_spree_test")
132
+
133
+ # set up spree-like A&B (different) test databases & files
134
+ db_a = create_spree_db(db_details.merge(:database=>"spree_test_a"))
135
+ path_a = create_spree_folder(tempdir,"spree_test_a",:test => db_details.merge(:database=>"spree_test_a"))
136
+ db_b = create_spree_db(db_details.merge(:database=>"spree_test_b"))
137
+ path_b = create_spree_folder(tempdir,"spree_test_b",:test => db_details.merge(:database=>"spree_test_b"))
138
+
139
+ DatabaseUtils::save_database(db_details.merge(:database=>"spree_test_a"),File.join(tempdir,'spree_test_a.sql'))
140
+ db_a_s = MiscUtils.string_from_file(File.join(tempdir,'spree_test_a.sql')).gsub!(/\n--.*$/,'')
141
+ DatabaseUtils::save_database(db_details.merge(:database=>"spree_test_b"),File.join(tempdir,'spree_test_b.sql'))
142
+ db_b_s = MiscUtils.string_from_file(File.join(tempdir,'spree_test_b.sql')).gsub!(/\n--.*$/,'')
143
+
144
+ files_a_s = filelist_with_sizes(path_a).join("\n")
145
+ files_products_a_s = filelist_with_sizes(File.join(path_a,'public/assets/products')).join("\n")
146
+ files_b_s = filelist_with_sizes(path_b).join("\n")
147
+ files_products_b_s = filelist_with_sizes(File.join(path_b,'public/assets/products')).join("\n")
148
+
149
+ assert_not_equal files_a_s,files_b_s
150
+ assert_not_equal files_products_a_s,files_products_b_s
151
+
152
+ # launch yore to save A to file system equivalent to :
153
+ # cd spree_test_a; yore save --app=spree --RAILS_ENV=test spree_test_a.tgz
154
+ @yore_a = YoreCore::Yore.launch(nil,{:kind => 'spree',:RAILS_ENV => 'test'},{:basepath => path_a})
155
+ spree_test_a_tgz = File.join(tempdir,'spree_test_a.tgz')
156
+ @yore_a.save(spree_test_a_tgz)
157
+
158
+ # launch yore to load file into B
159
+ @yore_b = YoreCore::Yore.launch(nil,{:kind => 'spree',:RAILS_ENV => 'test'},{:basepath => path_b})
160
+ @yore_b.load(spree_test_a_tgz)
161
+
162
+ DatabaseUtils::save_database(db_details.merge(:database=>"spree_test_b"),File.join(tempdir,'spree_test_b_after.sql'))
163
+ db_b_after_s = MiscUtils.string_from_file(File.join(tempdir,'spree_test_b_after.sql')).gsub!(/\n--.*$/,'')
164
+
165
+ # assert files in A & B are the same within public/assets/products, and different elsewhere
166
+ assert_not_equal db_a_s,db_b_s
167
+
168
+ db_a_s.gsub!(/\n--.*$/,'')
169
+ db_b_after_s.gsub!(/\n--.*$/,'')
170
+ MiscUtils.string_to_file(db_a_s,"/Users/gary/temp/db_a_s.txt")
171
+ MiscUtils.string_to_file(db_b_after_s,"/Users/gary/temp/db_b_after_s.txt")
172
+ assert_equal db_a_s,db_b_after_s
173
+
174
+ files_b_after_s = filelist_with_sizes(path_b).join("\n")
175
+ files_products_b_after_s = filelist_with_sizes(File.join(path_b,'public/assets/products')).join("\n")
176
+
177
+ assert_not_equal files_b_s,files_b_after_s
178
+ assert_not_equal files_products_b_after_s,files_products_b_s
179
+ assert_equal files_products_a_s,files_products_b_after_s
180
+ end
181
+
182
+ end
data/test/test_job_b.xml CHANGED
@@ -14,28 +14,21 @@
14
14
 
15
15
  <Item Name="mail_host">mail.authsmtp.com</Item>
16
16
  <Item Name="mail_port">25</Item>
17
- <Item Name="mail_helodomain">finwa.org.au</Item>
18
- <Item Name="mail_user">ac37391</Item>
19
- <Item Name="mail_password">mbju7wwzv</Item>
17
+ <Item Name="mail_helodomain">blah.com</Item>
18
+ <Item Name="mail_user">erewrwer</Item>
19
+ <Item Name="mail_password">werewrewr</Item>
20
20
  <Item Name="mail_from">noreply@buzzware.com.au</Item>
21
- <Item Name="mail_from_alias">FINWA Web Server</Item>
22
- <Item Name="mail_to">familyincnet@gmail.com</Item>
23
- <Item Name="mail_to_alias">FINWA</Item>
21
+ <Item Name="mail_from_alias">Web Server</Item>
22
+ <Item Name="mail_to">sadsd@blah.com</Item>
23
+ <Item Name="mail_to_alias">sdsadsd</Item>
24
24
  <Item Name="mail_auth">login</Item>
25
-
26
25
  <Item Name="mysqldump">/usr/local/mysql/bin/mysqldump</Item>
27
26
 
28
27
  </SimpleItems>
29
28
  <Sources>
30
29
  <Source Type="File">
31
30
  <IncludePath>/tmp/yoretest</IncludePath>
32
- <!-- <ExcludePath></ExcludePath> -->
33
31
  </Source>
34
- <!--<Source Type="MySql" > -->
35
- <!-- <Database Name="joomla_db" Host="localhost" User="root" Password="prot123ection">-->
36
- <!-- <ToFile>/Users/gary/temp/test.sql</ToFile> -->
37
- <!-- </Database> -->
38
- <!--</Source> -->
39
32
  </Sources>
40
33
  </Yore>
41
34
 
data/test/yore_test.rb CHANGED
@@ -1,22 +1,12 @@
1
1
  require 'rubygems'
2
2
  gem 'RequirePaths'; require 'require_paths'
3
- require_paths '../lib','../../..'
4
-
5
- require 'test/unit'
6
- gem 'Shoulda'; require 'shoulda'
7
-
8
-
3
+ require_paths '../../..','../lib'
9
4
  require 'ihl_ruby/misc_utils'
10
5
  require 'ihl_ruby/shell_extras'
11
-
12
- require 'fileutils'
13
-
14
6
  require 'yore/yore_core'
15
-
16
- def ensure_clean_bucket(aName)
17
- `s3cmd createbucket #{aName}`
18
- `s3cmd deleteall #{aName}`
19
- end
7
+ require 'test/unit'
8
+ gem 'Shoulda'; require 'shoulda'
9
+ require 'fileutils'
20
10
 
21
11
  class YoreTest < Test::Unit::TestCase
22
12
 
@@ -24,7 +14,7 @@ class YoreTest < Test::Unit::TestCase
24
14
  @yore = YoreCore::Yore.new
25
15
  end
26
16
 
27
- should "collect a list of files into a single file with a .contents file" do
17
+ should "collect a list of files into a single file" do
28
18
  # create a temp dir
29
19
  temp_dir = MiscUtils::make_temp_dir('yore_test')
30
20
  # create source and dest subfolders
@@ -38,22 +28,20 @@ class YoreTest < Test::Unit::TestCase
38
28
  end
39
29
  # collect into dest file
40
30
  # get recursive file list, without carrots
41
- filelist = MiscUtils::recursive_file_list(source_dir) {|p| not p =~ /carrots.txt/}
31
+ filelist = MiscUtils::recursive_file_list(source_dir,false) {|p| not p =~ /carrots.txt/}
42
32
  dest_file = File.join(dest_dir,'destfile.bzb')
43
33
 
44
- @yore.collect(filelist,dest_file)
34
+ @yore.compress(filelist,dest_file,source_dir)
45
35
 
46
- # check contains filelist files ignoring .contents
36
+ # check contains filelist files
47
37
  cmd = "tar --list --file=#{dest_file}"
48
38
  filelist_out = `#{cmd}`
49
39
  i = 0
50
40
  filelist_out.each_line {|line|
51
- next if line==".contents\n"
52
41
  assert i < filelist.length
53
- assert_equal line.chomp("\n"), MiscUtils.path_debase(filelist[i],source_dir) # .bite('/')
42
+ assert_equal line.chomp("\n"), filelist[i] # .bite('/')
54
43
  i += 1
55
44
  }
56
- # could also check .contents file against actual contents
57
45
  end
58
46
 
59
47
  should "encrypt and unencrypt a file with a standard iv but a supplied key" do
@@ -81,125 +69,8 @@ class YoreTest < Test::Unit::TestCase
81
69
  assert_equal Time.local(2008, 12, 31), @yore.decode_file_name(calc_filename)
82
70
  end
83
71
 
84
- should "upload and download files intact" do
85
- bucket = 'yore_test'
86
- ensure_clean_bucket(bucket)
87
- @yore.configure({
88
- :bucket => bucket
89
- })
90
- content = 'this is my test content'
91
- temp_dir = MiscUtils.make_temp_dir()
92
- temp_file = MiscUtils.make_temp_file(nil, temp_dir, content)
93
- puts @yore.upload(temp_file)
94
- orig_file = temp_file+'.orig'
95
- File.rename(temp_file, orig_file)
96
- puts @yore.download(temp_file)
97
- down_file_content = MiscUtils.string_from_file(temp_file)
98
- assert_equal content, down_file_content
99
- end
100
-
101
- should "backup and restore multiple directories of file" do
102
- # create a temp dir
103
- temp_dir = MiscUtils::make_temp_dir('yore_test')
104
- # create source and dest subfolders
105
- source_dir = File.expand_path('source',temp_dir)
106
- source1 = File.join(source_dir,'source1')
107
- source2 = File.join(source_dir,'source2')
108
- dest_dir = File.expand_path('dest',temp_dir)
109
- bucket = 'yore_test'
110
-
111
- FileUtils.mkdir_p([source1,source2,dest_dir])
112
- # create some dirs and files in source
113
- ['a','a/1','b','c'].each {|p| FileUtils.mkdir_p(File.expand_path(p,source1))}
114
- %w(a/blah.txt a/1/blahblah.txt b/apples.txt c/carrots.txt).each do |f|
115
- MiscUtils::make_temp_file(f,source1)
116
- end
117
- ['w','x/1','y/2','z'].each {|p| FileUtils.mkdir_p(File.expand_path(p,source2))}
118
- %w(w/zonk.txt x/1/eggs.txt y/2/bloop.txt z/zax.txt).each do |f|
119
- MiscUtils::make_temp_file(f,source2)
120
- end
121
-
122
- # create job file
123
- job_template = <<EOF
124
- <?xml version="1.0" encoding="UTF-8"?>
125
- <Yore>
126
- <SimpleItems>
127
- <Item Name="crypto_iv">3A63775C1E3F291B0925578165EB917E</Item>
128
- <Item Name="crypto_key">07692FC8656F04AE5518B80D38681E038A3C12050DF6CC97CEEC33D800D5E2FE</Item>
129
- <Item Name="prefix">backup</Item>
130
- <Item Name="log_level">INFO</Item>
131
- <Item Name="bucket">${BUCKET}</Item>
132
- </SimpleItems>
133
- <Sources>
134
- <Source Type="File">
135
- <IncludePath>${SOURCE1}</IncludePath>
136
- <IncludePath>${SOURCE2}</IncludePath>
137
- </Source>
138
- </Sources>
139
- </Yore>
140
- EOF
141
-
142
- job_content = StringUtils::render_template(job_template,{
143
- 'SOURCE1' => source1,
144
- 'SOURCE2' => source2,
145
- 'BUCKET' => bucket
146
- })
147
- MiscUtils::string_to_file(job_content,job_file = MiscUtils::temp_file)
148
-
149
- ensure_clean_bucket(bucket)
150
- @yore.configure({
151
- :bucket => bucket
152
- })
153
-
154
- # call yore script with ruby from the command line, then download result and check contents
155
- begin
156
- result = @yore.shell("ruby #{File.expand_path('../../bin/yore',THIS_DIR)} backup #{job_file}")
157
- rescue ::StandardError => e
158
- flunk e.inspect
159
- end
160
-
161
- puts result
162
-
163
- retrieved_fname = File.expand_path(@yore.encode_file_name(), dest_dir)
164
- collection_fname = MiscUtils::temp_file
165
-
166
- puts @yore.download(retrieved_fname)
167
- puts @yore.unpack(retrieved_fname,collection_fname)
168
-
169
- filelist = MiscUtils::recursive_file_list(source_dir,false)
170
-
171
- # check contains filelist files ignoring .contents
172
- cmd = "tar --list --file=#{collection_fname}"
173
- filelist_out = @yore.shell(cmd)
174
- filelist_out = filelist_out.split("\n").sort
175
- assert_equal filelist, filelist_out
176
- # i = 0
177
- # filelist_out.each {|line|
178
- # next if line==".contents\n"
179
- # i.should < filelist.length
180
- # line.chomp("\n").should == MiscUtils.path_debase(filelist[i],source_dir) # .bite('/')
181
- # i += 1
182
- # }
183
- # could also check .contents file against actual contents
184
- end
185
-
186
- should "handle test_file_b" do
187
- aController = YoreCore::Yore.new # main program object
188
- job = File.expand_path('../../test/test_job_b.xml',THIS_DIR)
189
- xmlRoot = XmlUtils.get_file_root(job)
190
- srcdir = '/tmp/yoretest'
191
- FileUtils.rm_rf srcdir+'/*'
192
- FileUtils.mkdir_p srcdir
193
- ['a','a/1','b','c'].each {|p| FileUtils.mkdir_p(File.expand_path(p,srcdir))}
194
- %w(a/blah.txt a/1/blahblah.txt b/apples.txt c/carrots.txt).each do |f|
195
- MiscUtils::make_temp_file(f,srcdir)
196
- end
197
-
198
- aController.configure(xmlRoot,nil,{:basepath => File.dirname(File.expand_path(job))})
199
- aController.backup(job)
200
- end
201
-
202
72
  should "provide configurable criteria for keeping old files"
203
73
 
204
74
  should "clean a folder full of files, removing files that don't match configurable criteria for keeping old files"
75
+
205
76
  end