Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add test to check if the per user stuff is found

  • Loading branch information...
commit c28713dbe96106e0ffcabcb9e7f6b1d0e7b13d16 1 parent ef64eba
Axel Beckert authored
Showing with 68 additions and 1 deletion.
  1. +1 −1  debian/changelog
  2. +67 −0 t/find-per-user-stuff.t
2  debian/changelog
View
@@ -6,13 +6,13 @@ unburden-home-dir (0.0.20120305) UNRELEASED; urgency=low
dpkg-maintscript-helper to rename conffiles.
* Let Xsession.d snippet also source ~/.unburden-home-dir to allow per
User execution
- + Add test for Xsession.d snippet
+ Call unburden-home-dir without hardcoded path
* Refactoring:
+ Use speaking variable names in fix_dangling_links() and do_it()
+ Reindent and reformat some overlong lines in bin/unburden-home-dir
+ Add semicolons on all return statements before block ends
+ Define list file suffix just once
+ * Add further tests to the test suite
* Improve README
* Add tmpreaper, eatmydata, agedu, bleachbit and some more comfortable
"du"-like tools to "Suggests".
67 t/find-per-user-stuff.t
View
@@ -0,0 +1,67 @@
+#!/usr/bin/perl -wl
+
+use Test::Simple tests => 16;
+use File::Path qw(mkpath rmtree);
+use File::Slurp;
+use Data::Dumper;
+
+my $BASE = 't/find-per-user-stuff';
+my $HOME = "$BASE/1";
+my $TARGET = "$BASE/2";
+my $BASENAME = "unburden-home-dir_TEST_$$";
+my $PREFIX = "u";
+
+# Set a debug environment
+$ENV{HOME} = $HOME;
+
+# Clean up possible remainders of aborted tests
+rmtree("$BASE");
+
+# 1 - 3
+ok( mkpath("$HOME/.foobar/fnord/bla", "$TARGET", {}), "Create test environment (directories)" );
+ok( -d "$HOME/.foobar/fnord/bla", "Original directory has been created" );
+ok( -d "$TARGET", "Target directory has been created" );
+
+# 4 - 7
+ok( symlink("$HOME/.foobar/fnord", "$HOME/.fnord"), "Create test environment (Symlink 1)" );
+ok( -l "$HOME/.fnord", "Symlink 1 has been created" );
+ok( symlink("fnord", "$HOME/.foobar/blafasel"), "Create test environment (Symlink 2)" );
+ok( -l "$HOME/.foobar/blafasel", "Symlink 2 has been created" );
+
+# 8 + 9
+ok( write_file("$HOME/.$BASENAME.list", "m d .foobar/fnord/bla foobar-fnord-bla\nm d .fnord/bla fnord-bla\nm d .foobar/blafasel/bla foobar-blafasel-bla\n") );
+ok( write_file("$HOME/.$BASENAME", "TARGETDIR=$TARGET\nFILELAYOUT=$PREFIX-\%s") );
+
+# 10
+my $cmd = "bin/unburden-home-dir -b $BASENAME > $BASE/output 2> $BASE/stderr";
+ok( system($cmd) == 0, "Call '$cmd'" );
+
+# 11
+my $wanted = "Skipping '$HOME/.fnord/bla' due to symlink in path: $HOME/.fnord
+Skipping '$HOME/.foobar/blafasel/bla' due to symlink in path: $HOME/.foobar/blafasel
+";
+
+my $stderr = read_file("$BASE/stderr");
+print "Want:\n\n$wanted\nGot:\n\n$stderr\n";
+ok( $stderr eq $wanted, "Check command STDERR output" );
+
+# 12
+$wanted = "Moving $HOME/.foobar/fnord/bla -> $TARGET/u-foobar-fnord-bla
+sending incremental file list
+created directory $TARGET/u-foobar-fnord-bla
+./
+Symlinking $TARGET/u-foobar-fnord-bla -> $HOME/.foobar/fnord/bla
+";
+
+my $output = read_file("$BASE/output");
+print "Want:\n\n$wanted\nGot:\n\n$output\n";
+ok( $output eq $wanted, "Check command STDOUT" );
+
+# 13 - 15
+ok( -d "$TARGET/$PREFIX-foobar-fnord-bla", "First directory moved" );
+ok( ! -e "$TARGET/$PREFIX-fnord-bla", "Symlink 1 not moved" );
+ok( ! -e "$TARGET/$PREFIX-foobar-blafasel-bla", "Symlink 2 not moved" );
+
+
+# 16
+ok( rmtree("$BASE"), "Clean up" );
Please sign in to comment.
Something went wrong with that request. Please try again.