def test_revert_01(self): write_probe('''#!/usr/bin/env bash echo hello world from probe! | tee bar mv eggs eggs2 ls -l foo/spam rm foo/spam''') pipeline = self.pipeline_loader.load_pipeline('run-probe-1') namespace = pmatic.Namespace() scan1 = pmatic.scan_directory(self.test_dir) pipeline.run(namespace) scan2 = pmatic.scan_directory(self.test_dir) self.assertNotEqual(scan1, scan2) pprint.pprint(scan1) pprint.pprint(scan2) os.chdir('..') pmatic.restore_snapshot(scan1, self.test_dir) scan3 = pmatic.scan_directory(self.test_dir) pprint.pprint(scan3) self.maxDiff = None self.assertEqual(scan1, scan3)
def test_revert_02(self): write_probe( """#!/usr/bin/env bash echo hello world from probe! | tee bar mv eggs eggs2 mkdir -p new-foo echo new spam in new-foo| tee new-foo/spam ln -s new-foo/spam eggs """ ) pipeline = self.pipeline_loader.load_pipeline("run-probe-1") namespace = pmatic.Namespace() scan1 = pmatic.scan_directory(".") pipeline.run(namespace) scan2 = pmatic.scan_directory(".") self.assertNotEqual(scan1, scan2) pprint.pprint(scan1) pprint.pprint(scan2) pmatic.restore_snapshot(scan1, ".") scan3 = pmatic.scan_directory(".") pprint.pprint(scan3) self.maxDiff = None self.assertEqual(scan1, scan3)