This repository was archived by the owner on Apr 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy patht0052-object-diff.sh
executable file
·80 lines (63 loc) · 2.11 KB
/
t0052-object-diff.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh
#
# Copyright (c) 2016 Jeromy Johnson
# MIT Licensed; see the LICENSE file in this repository.
#
test_description="Test object diff command"
. lib/test-lib.sh
test_init_ipfs
test_expect_success "create some objects for testing diffs" '
mkdir foo &&
echo "stuff" > foo/bar &&
mkdir foo/baz &&
A=$(ipfs add -r -q foo | tail -n1) &&
echo "more things" > foo/cat &&
B=$(ipfs add -r -q foo | tail -n1) &&
echo "nested" > foo/baz/dog &&
C=$(ipfs add -r -q foo | tail -n1)
echo "changed" > foo/bar &&
D=$(ipfs add -r -q foo | tail -n1)
'
test_expect_success "diff against self is empty" '
ipfs object diff $A $A > diff_out
'
test_expect_success "identity diff output looks good" '
printf "" > diff_exp &&
test_cmp diff_exp diff_out
'
test_expect_success "diff added link works" '
ipfs object diff $A $B > diff_out
'
test_expect_success "diff added link looks right" '
echo + QmUSvcqzhdfYM1KLDbM76eLPdS9ANFtkJvFuPYeZt73d7A \"cat\" > diff_exp &&
test_cmp diff_exp diff_out
'
test_expect_success "verbose diff added link works" '
ipfs object diff -v $A $B > diff_out
'
test_expect_success "verbose diff added link looks right" '
echo Added new link \"cat\" pointing to QmUSvcqzhdfYM1KLDbM76eLPdS9ANFtkJvFuPYeZt73d7A. > diff_exp &&
test_cmp diff_exp diff_out
'
test_expect_success "diff removed link works" '
ipfs object diff -v $B $A > diff_out
'
test_expect_success "diff removed link looks right" '
echo Removed link \"cat\" \(was QmUSvcqzhdfYM1KLDbM76eLPdS9ANFtkJvFuPYeZt73d7A\). > diff_exp &&
test_cmp diff_exp diff_out
'
test_expect_success "diff nested add works" '
ipfs object diff -v $B $C > diff_out
'
test_expect_success "diff looks right" '
echo Added new link \"baz/dog\" pointing to QmdNJQUTZuDpsUcec7YDuCfRfvw1w4J13DCm7YcU4VMZdS. > diff_exp &&
test_cmp diff_exp diff_out
'
test_expect_success "diff changed link works" '
ipfs object diff -v $C $D > diff_out
'
test_expect_success "diff looks right" '
echo Changed \"bar\" from QmNgd5cz2jNftnAHBhcRUGdtiaMzb5Rhjqd4etondHHST8 to QmRfFVsjSXkhFxrfWnLpMae2M4GBVsry6VAuYYcji5MiZb. > diff_exp &&
test_cmp diff_exp diff_out
'
test_done