Add sharness tests for files stat format options
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
Jakub Sztandera committed
May 18, 2016 at 06:58 UTC
64677e75a3ea3560438a7ee3984fa571f4d8489e
1 file changed
+30
test/sharness/t0250-files-api.sh
+30
@@ -64,6 +64,36 @@ test_files_api() {
64
test_expect_success "directory is empty" '
65
verify_dir_contents /cats
66
'
67
+ # we do verification of stat formatting now as we depend on it
68
+
69
+ test_expect_success "stat works" '
70
+ ipfs files stat / >stat
71
+ '
72
+
73
+ test_expect_success "hash is first line of stat" '
74
+ ipfs ls $(head -1 stat) | grep "cats"
75
+ '
76
+
77
+ test_expect_success "stat --hash gives only hash" '
78
+ ipfs files stat --hash / >actual &&
79
+ head -1 stat >expected &&
80
+ test_cmp expected actual
81
+ '
82
+
83
+ test_expect_success "stat with multiple format options should fail" '
84
+ test_must_fail ipfs files stat --hash --size /
85
+ '
86
+
87
+ test_expect_success "compare hash option with format" '
88
+ ipfs files stat --hash / >expected &&
89
+ ipfs files stat --format='"'"'<hash>'"'"' / >actual &&
90
+ test_cmp expected actual
91
+ '
92
+ test_expect_success "compare size option with format" '
93
+ ipfs files stat --size / >expected &&
94
+ ipfs files stat --format='"'"'<cumulsize>'"'"' / >actual &&
95
+ test_cmp expected actual
96
+ '
97
98
test_expect_success "check root hash" '
99
ipfs files stat / | head -n1 > roothash