Skip to content

Commit b96e542

Browse files
committed
[TEST] add tests for json and inc
1 parent aa6a49c commit b96e542

7 files changed

+161
-0
lines changed

test/cache_test.sh

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ cp -a test/ test_tmp/
66
cd test_tmp
77
run ls
88

9+
# run tests
910
run cache snapshots
1011
run ls
1112

test/inc_test.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
source test/_tools.sh
2+
3+
# setup stuff to test cache
4+
mkdir test_tmp
5+
echo '{
6+
"name": "test",
7+
"version": "1.2.3",
8+
"description": "See if the inc program works well"
9+
}' > test_tmp/package.json
10+
11+
echo '{
12+
"name": "test",
13+
"version": "1.2.3",
14+
"description": "See if the inc program works well"
15+
}' > test_tmp/bower.json
16+
17+
cd test_tmp
18+
19+
print_versions () {
20+
echo package.json "-->" `grep version package.json`
21+
echo bower.json " -->" `grep version bower.json`
22+
}
23+
24+
# run tests
25+
run inc patch
26+
print_versions
27+
28+
run inc minor
29+
print_versions
30+
31+
run inc major
32+
print_versions
33+
34+
# clean up
35+
cd - >/dev/null
36+
rm -rf test_tmp 2>/dev/null

test/index.sh

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ testFiles="""
22
bashful_test.sh
33
parse-args_test.sh
44
cache_test.sh
5+
inc_test.sh
6+
json_test.sh
57
"""
68

79
[ ! -z "$1" ] && [ "$1" != "--update-snapshots" ] && testFiles="$1_test.sh";

test/json_test.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
source test/_tools.sh
2+
3+
# setup stuff to test cache
4+
mkdir test_tmp
5+
echo '{
6+
"name": "test",
7+
"version": "1.2.3",
8+
"description": "See if the json program works well",
9+
"list": [
10+
"item1",
11+
"item2",
12+
"item3",
13+
"item4"
14+
]
15+
}' > test_tmp/package.json
16+
17+
cd test_tmp
18+
19+
# run tests
20+
run json package.json
21+
run json package.json '$'
22+
run json package.json '$.description'
23+
24+
# Had issues with 'run' and the exec string, so just style it here
25+
div ___
26+
echo "RUNNING > 'json package.json '$.list.map(x=>\`\${$.name}_\${x.toUpperCase()}\`)''"
27+
div ..
28+
json package.json '$.list.map(x=>`${$.name}_${x.toUpperCase()}`)'
29+
div ..
30+
div ___
31+
32+
33+
# clean up
34+
cd - >/dev/null
35+
rm -rf test_tmp 2>/dev/null

test/snapshots/cache_test.sh.snapshot

+12
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ RUNNING > 'ls'
77
_tools.sh
88
bashful_test.sh
99
cache_test.sh
10+
inc_test.sh
1011
index.sh
12+
json_test.sh
1113
parse-args
1214
parse-args_test.sh
1315
results
@@ -27,7 +29,9 @@ RUNNING > 'ls'
2729
_tools.sh
2830
bashful_test.sh
2931
cache_test.sh
32+
inc_test.sh
3033
index.sh
34+
json_test.sh
3135
parse-args
3236
parse-args_test.sh
3337
results
@@ -48,7 +52,9 @@ RUNNING > 'ls'
4852
_tools.sh
4953
bashful_test.sh
5054
cache_test.sh
55+
inc_test.sh
5156
index.sh
57+
json_test.sh
5258
parse-args_test.sh
5359
................................................................
5460
________________________________________________________________________________________________
@@ -67,7 +73,9 @@ RUNNING > 'ls'
6773
_tools.sh
6874
bashful_test.sh
6975
cache_test.sh
76+
inc_test.sh
7077
index.sh
78+
json_test.sh
7179
parse-args_test.sh
7280
................................................................
7381
________________________________________________________________________________________________
@@ -84,7 +92,9 @@ RUNNING > 'ls'
8492
_tools.sh
8593
bashful_test.sh
8694
cache_test.sh
95+
inc_test.sh
8796
index.sh
97+
json_test.sh
8898
parse-args
8999
parse-args_test.sh
90100
results
@@ -102,7 +112,9 @@ RUNNING > 'ls'
102112
_tools.sh
103113
bashful_test.sh
104114
cache_test.sh
115+
inc_test.sh
105116
index.sh
117+
json_test.sh
106118
parse-args
107119
parse-args_test.sh
108120
results

test/snapshots/inc_test.sh.snapshot

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#####################################################################################################
2+
# TESTING inc_test.sh
3+
#####################################################################################################
4+
________________________________________________________________________________________________
5+
RUNNING > 'inc patch'
6+
................................................................
7+
Moving 1.2.3 --> 1.2.4
8+
bower.json updated.
9+
package.json updated.
10+
................................................................
11+
________________________________________________________________________________________________
12+
package.json --> "version": "1.2.4",
13+
bower.json --> "version": "1.2.4",
14+
________________________________________________________________________________________________
15+
RUNNING > 'inc minor'
16+
................................................................
17+
Moving 1.2.4 --> 1.3.0
18+
bower.json updated.
19+
package.json updated.
20+
................................................................
21+
________________________________________________________________________________________________
22+
package.json --> "version": "1.3.0",
23+
bower.json --> "version": "1.3.0",
24+
________________________________________________________________________________________________
25+
RUNNING > 'inc major'
26+
................................................................
27+
Moving 1.3.0 --> 2.0.0
28+
bower.json updated.
29+
package.json updated.
30+
................................................................
31+
________________________________________________________________________________________________
32+
package.json --> "version": "2.0.0",
33+
bower.json --> "version": "2.0.0",
34+
#####################################################################################################

test/snapshots/json_test.sh.snapshot

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#####################################################################################################
2+
# TESTING json_test.sh
3+
#####################################################################################################
4+
________________________________________________________________________________________________
5+
RUNNING > 'json package.json'
6+
................................................................
7+
{
8+
"name": "test",
9+
"version": "1.2.3",
10+
"description": "See if the json program works well",
11+
"list": [
12+
"item1",
13+
"item2",
14+
"item3",
15+
"item4"
16+
]
17+
}
18+
................................................................
19+
________________________________________________________________________________________________
20+
________________________________________________________________________________________________
21+
RUNNING > 'json package.json $'
22+
................................................................
23+
{ name: 'test',
24+
version: '1.2.3',
25+
description: 'See if the json program works well',
26+
list: [ 'item1', 'item2', 'item3', 'item4' ] }
27+
................................................................
28+
________________________________________________________________________________________________
29+
________________________________________________________________________________________________
30+
RUNNING > 'json package.json $.description'
31+
................................................................
32+
See if the json program works well
33+
................................................................
34+
________________________________________________________________________________________________
35+
________________________________________________________________________________________________
36+
RUNNING > 'json package.json '$.list.map(x=>`${$.name}_${x.toUpperCase()}`)''
37+
................................................................
38+
[ 'test_ITEM1', 'test_ITEM2', 'test_ITEM3', 'test_ITEM4' ]
39+
................................................................
40+
________________________________________________________________________________________________
41+
#####################################################################################################

0 commit comments

Comments
 (0)