@cryptotaxi247 / kubo / commits / 533a72994

add sharness test for tar commands

License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>

Jeromy committed Sep 10, 2015 at 17:11 UTC 533a729949f09556aca3f82fd19d6b7257bb4b9b
1 file changed +49
test/sharness/t0210-tar.sh new
+49
@@ -0,0 +1,49 @@
1 +#!/bin/sh
2 +#
3 +# Copyright (c) 2015 Jeromy Johnson
4 +# MIT Licensed; see the LICENSE file in this repository.
5 +#
6 +
7 +test_description="Test tar commands"
8 +
9 +. lib/test-lib.sh
10 +
11 +test_init_ipfs
12 +
13 +test_expect_success "create some random files" '
14 + mkdir foo &&
15 + random 10000 > foo/a &&
16 + random 12345 > foo/b &&
17 + mkdir foo/bar &&
18 + random 5432 > foo/bar/baz &&
19 + ln -s ../a foo/bar/link &&
20 + echo "exit" > foo/script &&
21 + chmod +x foo/script
22 +'
23 +
24 +test_expect_success "tar those random files up" '
25 + tar cf files.tar foo/
26 +'
27 +
28 +test_expect_success "'ipfs tar add' succeeds" '
29 + TAR_HASH=$(ipfs tar add files.tar)
30 +'
31 +
32 +test_expect_success "'ipfs tar cat' succeeds" '
33 + mkdir output &&
34 + ipfs tar cat $TAR_HASH > output/out.tar
35 +'
36 +
37 +test_expect_success "can extract tar" '
38 + tar xf output/out.tar -C output/
39 +'
40 +
41 +test_expect_success "files look right" '
42 + diff foo/a output/foo/a &&
43 + diff foo/b output/foo/b &&
44 + diff foo/bar/baz output/foo/bar/baz &&
45 + [ -L output/foo/bar/link ] &&
46 + [ -x foo/script ]
47 +'
48 +
49 +test_done