@cryptotaxi247 / kubo / commits / 2a0cd6d3d

object: added sharness tests for get, put and stat

Henry committed Mar 7, 2015 at 13:25 UTC 2a0cd6d3d35ebc0aed9046f98f9b11dff5198131
4 files changed +95
test/sharness/t0051-object-data/expected_getOut new
+4
@@ -0,0 +1,4 @@
1 +{
2 + "Links": [],
3 + "Data": "\u0008\u0002\u0012\nHello Mars\u0018\n"
4 +}
\ No newline at end of file
test/sharness/t0051-object-data/testPut.json new
+3
@@ -0,0 +1,3 @@
1 +{
2 + "Data": "test json for sharness test"
3 +}
test/sharness/t0051-object-data/testPut.pb new
+2
@@ -0,0 +1,2 @@
1 +
2 +test json for sharness test
\ No newline at end of file
test/sharness/t0051-object.sh new
+86
@@ -0,0 +1,86 @@
1 +#!/bin/sh
2 +#
3 +# Copyright (c) 2015 Henry Bubert
4 +# MIT Licensed; see the LICENSE file in this repository.
5 +#
6 +
7 +test_description="Test object command"
8 +
9 +. lib/test-lib.sh
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 +
86 +test_done