1 module unit_threaded.ut.integration; 2 3 import unit_threaded.integration; 4 5 @safe unittest { 6 auto sb = Sandbox(); 7 assert(sb.testPath != ""); 8 } 9 10 @safe unittest { 11 import std.file: exists, rmdirRecurse; 12 import std.path: buildPath; 13 import unit_threaded.should; 14 15 Sandbox.sandboxesPath.shouldEqual(Sandbox.defaultSandboxesPath); 16 17 immutable newPath = buildPath("foo", "bar", "baz"); 18 assert(!newPath.exists); 19 Sandbox.setPath(newPath); 20 assert(newPath.exists); 21 scope(exit) () @trusted { rmdirRecurse("foo"); }(); 22 Sandbox.sandboxesPath.shouldEqual(newPath); 23 24 with(immutable Sandbox()) { 25 writeFile("newPath.txt"); 26 assert(buildPath(newPath, testPath, "newPath.txt").exists); 27 } 28 29 Sandbox.resetPath; 30 Sandbox.sandboxesPath.shouldEqual(Sandbox.defaultSandboxesPath); 31 } 32 33 34 @safe unittest { 35 import std.file: exists; 36 import std.path: buildPath; 37 38 with(immutable Sandbox()) { 39 assert(!buildPath(testPath, "foo.txt").exists); 40 writeFile("foo.txt"); 41 assert(buildPath(testPath, "foo.txt").exists); 42 } 43 } 44 45 @safe unittest { 46 import std.file: exists; 47 import std.path: buildPath; 48 49 with(immutable Sandbox()) { 50 writeFile("foo/bar.txt"); 51 assert(buildPath(testPath, "foo", "bar.txt").exists); 52 } 53 } 54 55 @safe unittest { 56 with(immutable Sandbox()) { 57 import unit_threaded.should; 58 59 shouldExist("bar.txt").shouldThrow; 60 writeFile("bar.txt"); 61 shouldExist("bar.txt"); 62 } 63 } 64 65 @safe unittest { 66 with(immutable Sandbox()) { 67 import unit_threaded.should; 68 69 shouldNotExist("baz.txt"); 70 writeFile("baz.txt"); 71 shouldNotExist("baz.txt").shouldThrow; 72 } 73 } 74 75 76 @safe unittest { 77 with(immutable Sandbox()) { 78 import unit_threaded.should; 79 80 writeFile("lines.txt", ["foo", "toto"]); 81 shouldEqualLines("lines.txt", ["foo", "bar"]).shouldThrow; 82 shouldEqualLines("lines.txt", ["foo", "toto"]); 83 } 84 }