@cryptotaxi247 / kubo / commits / 327c59f7f

t0051: test ipfs object online as well as offline

To do that the current tests are move inside a test_object_cmd() function. This function is then first called before running the daemon for offline tests and then after starting the daemon for online tests. License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>

Christian Couder committed Mar 29, 2015 at 18:30 UTC 327c59f7f0541321f5095ce45b2eb4843800b032
1 file changed +93 -83
test/sharness/t0051-object.sh
+93 -83
@@ -10,88 +10,98 @@ test_description="Test object command"
10
11 test_init_ipfs
12
13 -test_expect_success "'ipfs add testData' succeeds" '
14 - printf "Hello Mars" >expected_in &&
15 - ipfs add expected_in >actual_Addout
16 -'
17 -
18 -test_expect_success "'ipfs add testData' output looks good" '
19 - HASH="QmWkHFpYBZ9mpPRreRbMhhYWXfUhBAue3JkbbpFqwowSRb" &&
20 - echo "added $HASH expected_in" >expected_Addout &&
21 - test_cmp expected_Addout actual_Addout
22 -'
23 -
24 -test_expect_success "'ipfs object get' succeeds" '
25 - ipfs object get $HASH >actual_getOut
26 -'
27 -
28 -test_expect_success "'ipfs object get' output looks good" '
29 - test_cmp ../t0051-object-data/expected_getOut actual_getOut
30 -'
31 -
32 -test_expect_success "'ipfs object stat' succeeds" '
33 - ipfs object stat $HASH >actual_stat
34 -'
35 -
36 -test_expect_success "'ipfs object get' output looks good" '
37 - echo "NumLinks: 0" > expected_stat &&
38 - echo "BlockSize: 18" >> expected_stat &&
39 - echo "LinksSize: 2" >> expected_stat &&
40 - echo "DataSize: 16" >> expected_stat &&
41 - echo "CumulativeSize: 18" >> expected_stat &&
42 - test_cmp expected_stat actual_stat
43 -'
44 -
45 -test_expect_success "'ipfs object put file.json' succeeds" '
46 - ipfs object put ../t0051-object-data/testPut.json > actual_putOut
47 -'
48 -
49 -test_expect_success "'ipfs object put file.json' output looks good" '
50 - HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
51 - printf "added $HASH" > expected_putOut &&
52 - test_cmp expected_putOut actual_putOut
53 -'
54 -
55 -test_expect_success "'ipfs object put file.pb' succeeds" '
56 - ipfs object put --inputenc=protobuf ../t0051-object-data/testPut.pb > actual_putOut
57 -'
58 -
59 -test_expect_success "'ipfs object put file.pb' output looks good" '
60 - HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
61 - printf "added $HASH" > expected_putOut &&
62 - test_cmp expected_putOut actual_putOut
63 -'
64 -
65 -test_expect_success "'ipfs object put' from stdin succeeds" '
66 - cat ../t0051-object-data/testPut.json | ipfs object put > actual_putStdinOut
67 -'
68 -
69 -test_expect_success "'ipfs object put' from stdin output looks good" '
70 - HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
71 - printf "added $HASH" > expected_putStdinOut &&
72 - test_cmp expected_putStdinOut actual_putStdinOut
73 -'
74 -
75 -test_expect_success "'ipfs object put' from stdin (pb) succeeds" '
76 - cat ../t0051-object-data/testPut.pb | ipfs object put --inputenc=protobuf > actual_putPbStdinOut
77 -'
78 -
79 -test_expect_success "'ipfs object put' from stdin (pb) output looks good" '
80 - HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
81 - printf "added $HASH" > expected_putStdinOut &&
82 - test_cmp expected_putStdinOut actual_putPbStdinOut
83 -'
84 -
85 -test_expect_success "'ipfs object put broken.json' should fail" '
86 - test_expect_code 1 ipfs object put ../t0051-object-data/brokenPut.json 2>actual_putBrokenErr >actual_putBroken
87 -'
88 -
89 -test_expect_success "'ipfs object put broken.hjson' output looks good" '
90 - touch expected_putBroken &&
91 - printf "Error: no data or links in this node\n" > expected_putBrokenErr &&
92 - test_cmp expected_putBroken actual_putBroken &&
93 - test_cmp expected_putBrokenErr actual_putBrokenErr
94 -'
95 -
13 +test_object_cmd() {
14 +
15 + test_expect_success "'ipfs add testData' succeeds" '
16 + printf "Hello Mars" >expected_in &&
17 + ipfs add expected_in >actual_Addout
18 + '
19 +
20 + test_expect_success "'ipfs add testData' output looks good" '
21 + HASH="QmWkHFpYBZ9mpPRreRbMhhYWXfUhBAue3JkbbpFqwowSRb" &&
22 + echo "added $HASH expected_in" >expected_Addout &&
23 + test_cmp expected_Addout actual_Addout
24 + '
25 +
26 + test_expect_success "'ipfs object get' succeeds" '
27 + ipfs object get $HASH >actual_getOut
28 + '
29 +
30 + test_expect_success "'ipfs object get' output looks good" '
31 + test_cmp ../t0051-object-data/expected_getOut actual_getOut
32 + '
33 +
34 + test_expect_success "'ipfs object stat' succeeds" '
35 + ipfs object stat $HASH >actual_stat
36 + '
37 +
38 + test_expect_success "'ipfs object get' output looks good" '
39 + echo "NumLinks: 0" > expected_stat &&
40 + echo "BlockSize: 18" >> expected_stat &&
41 + echo "LinksSize: 2" >> expected_stat &&
42 + echo "DataSize: 16" >> expected_stat &&
43 + echo "CumulativeSize: 18" >> expected_stat &&
44 + test_cmp expected_stat actual_stat
45 + '
46 +
47 + test_expect_success "'ipfs object put file.json' succeeds" '
48 + ipfs object put ../t0051-object-data/testPut.json > actual_putOut
49 + '
50 +
51 + test_expect_success "'ipfs object put file.json' output looks good" '
52 + HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
53 + printf "added $HASH" > expected_putOut &&
54 + test_cmp expected_putOut actual_putOut
55 + '
56 +
57 + test_expect_success "'ipfs object put file.pb' succeeds" '
58 + ipfs object put --inputenc=protobuf ../t0051-object-data/testPut.pb > actual_putOut
59 + '
60 +
61 + test_expect_success "'ipfs object put file.pb' output looks good" '
62 + HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
63 + printf "added $HASH" > expected_putOut &&
64 + test_cmp expected_putOut actual_putOut
65 + '
66 +
67 + test_expect_success "'ipfs object put' from stdin succeeds" '
68 + cat ../t0051-object-data/testPut.json | ipfs object put > actual_putStdinOut
69 + '
70 +
71 + test_expect_success "'ipfs object put' from stdin output looks good" '
72 + HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
73 + printf "added $HASH" > expected_putStdinOut &&
74 + test_cmp expected_putStdinOut actual_putStdinOut
75 + '
76 +
77 + test_expect_success "'ipfs object put' from stdin (pb) succeeds" '
78 + cat ../t0051-object-data/testPut.pb | ipfs object put --inputenc=protobuf > actual_putPbStdinOut
79 + '
80 +
81 + test_expect_success "'ipfs object put' from stdin (pb) output looks good" '
82 + HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
83 + printf "added $HASH" > expected_putStdinOut &&
84 + test_cmp expected_putStdinOut actual_putPbStdinOut
85 + '
86 +
87 + test_expect_success "'ipfs object put broken.json' should fail" '
88 + test_expect_code 1 ipfs object put ../t0051-object-data/brokenPut.json 2>actual_putBrokenErr >actual_putBroken
89 + '
90 +
91 + test_expect_success "'ipfs object put broken.hjson' output looks good" '
92 + touch expected_putBroken &&
93 + printf "Error: no data or links in this node\n" > expected_putBrokenErr &&
94 + test_cmp expected_putBroken actual_putBroken &&
95 + test_cmp expected_putBrokenErr actual_putBrokenErr
96 + '
97 +}
98 +
99 +# should work offline
100 +test_object_cmd
101 +
102 +# should work online
103 +test_launch_ipfs_daemon
104 +test_object_cmd
105 +test_kill_ipfs_daemon
106
107 test_done