Skip to content

Instantly share code, notes, and snippets.

@clayg
Created November 6, 2015 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clayg/6a455fd71943256023fb to your computer and use it in GitHub Desktop.
Save clayg/6a455fd71943256023fb to your computer and use it in GitHub Desktop.
this is a little on the nose, but should get to the meat of it
diff --git a/test/unit/obj/test_diskfile.py b/test/unit/obj/test_diskfile.py
index c602912..a0d4da1 100644
--- a/test/unit/obj/test_diskfile.py
+++ b/test/unit/obj/test_diskfile.py
@@ -2801,6 +2801,28 @@ class DiskFileMixin(BaseDiskFileTestMixin):
self.assertTrue(exp_name in set(dl),
'Expected file %s not found in %s' % (exp_name, dl))
+ def test_cleanup_older_metadata_when_combined_older_content_type(self):
+ # if metadata has content-type then its time should be in file name
+ ts_iter = make_timestamp_iter()
+ df = self._create_test_file('1234567890', timestamp=ts_iter.next())
+ file_count = len(os.listdir(df._datadir))
+ timestamp = ts_iter.next()
+ timestamp2 = ts_iter.next()
+ metadata = {'X-Timestamp': timestamp2.internal,
+ 'X-Object-Meta-test': 'data'}
+ df.write_metadata(metadata)
+ metadata = {'X-Timestamp': timestamp2.internal,
+ 'X-Object-Meta-test': 'data',
+ 'Content-Type': 'foo',
+ 'Content-Type-Timestamp': timestamp.internal}
+ df.write_metadata(metadata)
+ dl = df.manager.hash_cleanup_listdir(df._datadir)
+ self.assertEqual(len(dl), file_count + 1, dl)
+ exp_name = '%s-%x.meta' % (timestamp2.internal,
+ timestamp2.raw - timestamp.raw)
+ self.assertTrue(exp_name in set(dl),
+ 'Expected file %s not found in %s' % (exp_name, dl))
+
def test_write_metadata_no_xattr(self):
timestamp = Timestamp(time()).internal
metadata = {'X-Timestamp': timestamp, 'X-Object-Meta-test': 'data'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment