mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
object: added sharness tests for get, put and stat
This commit is contained in:
parent
bc84ffafe3
commit
2a0cd6d3d3
4
test/sharness/t0051-object-data/expected_getOut
Normal file
4
test/sharness/t0051-object-data/expected_getOut
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"Links": [],
|
||||
"Data": "\u0008\u0002\u0012\nHello Mars\u0018\n"
|
||||
}
|
||||
3
test/sharness/t0051-object-data/testPut.json
Normal file
3
test/sharness/t0051-object-data/testPut.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"Data": "test json for sharness test"
|
||||
}
|
||||
2
test/sharness/t0051-object-data/testPut.pb
Normal file
2
test/sharness/t0051-object-data/testPut.pb
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
test json for sharness test
|
||||
86
test/sharness/t0051-object.sh
Executable file
86
test/sharness/t0051-object.sh
Executable file
@ -0,0 +1,86 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2015 Henry Bubert
|
||||
# MIT Licensed; see the LICENSE file in this repository.
|
||||
#
|
||||
|
||||
test_description="Test object command"
|
||||
|
||||
. lib/test-lib.sh
|
||||
|
||||
test_init_ipfs
|
||||
|
||||
test_expect_success "'ipfs add testData' succeeds" '
|
||||
printf "Hello Mars" >expected_in &&
|
||||
ipfs add expected_in >actual_Addout
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs add testData' output looks good" '
|
||||
HASH="QmWkHFpYBZ9mpPRreRbMhhYWXfUhBAue3JkbbpFqwowSRb" &&
|
||||
echo "added $HASH expected_in" >expected_Addout &&
|
||||
test_cmp expected_Addout actual_Addout
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs object get' succeeds" '
|
||||
ipfs object get $HASH >actual_getOut
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs object get' output looks good" '
|
||||
test_cmp ../t0051-object-data/expected_getOut actual_getOut
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs object stat' succeeds" '
|
||||
ipfs object stat $HASH >actual_stat
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs object get' output looks good" '
|
||||
echo "NumLinks: 0" >> expected_stat &&
|
||||
echo "BlockSize: 18" >> expected_stat &&
|
||||
echo "LinksSize: 2" >> expected_stat &&
|
||||
echo "DataSize: 16" >> expected_stat &&
|
||||
echo "CumulativeSize: 18" >> expected_stat &&
|
||||
test_cmp expected_stat actual_stat
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs object put file.json' succeeds" '
|
||||
ipfs object put ../t0051-object-data/testPut.json > actual_putOut
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs object put file.json' output looks good" '
|
||||
HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
|
||||
printf "added $HASH" > expected_putOut &&
|
||||
test_cmp expected_putOut actual_putOut
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs object put file.pb' succeeds" '
|
||||
ipfs object put --inputenc=protobuf ../t0051-object-data/testPut.pb > actual_putOut
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs object put file.pb' output looks good" '
|
||||
HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
|
||||
printf "added $HASH" > expected_putOut &&
|
||||
test_cmp expected_putOut actual_putOut
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs object put' from stdin succeeds" '
|
||||
cat ../t0051-object-data/testPut.json | ipfs object put > actual_putStdinOut
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs object put' from stdin output looks good" '
|
||||
HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
|
||||
printf "added $HASH" > expected_putStdinOut &&
|
||||
test_cmp expected_putStdinOut actual_putStdinOut
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs object put' from stdin (pb) succeeds" '
|
||||
cat ../t0051-object-data/testPut.pb | ipfs object put --inputenc=protobuf > actual_putPbStdinOut
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs object put' from stdin (pb) output looks good" '
|
||||
HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
|
||||
printf "added $HASH" > expected_putStdinOut &&
|
||||
test_cmp expected_putStdinOut actual_putPbStdinOut
|
||||
'
|
||||
|
||||
|
||||
test_done
|
||||
Loading…
Reference in New Issue
Block a user