-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·59 lines (47 loc) · 1.48 KB
/
test.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
#!/usr/bin/env bash
mkdir -p test_samples
# Make sure images are up-to-date:
docker pull stratumn/go-chainscript:latest
docker pull stratumn/js-chainscript:latest
# Mount a directory for reading/writing samples.
MOUNT=type=bind,source="$(pwd)"/test_samples,target=/samples
# Go container details.
GO_CONTAINER=stratumn/go-chainscript:latest
GO_CONTAINER_SAMPLE_FILE=/samples/go-samples.json
# Javascript container details.
JS_CONTAINER=stratumn/js-chainscript:latest
JS_CONTAINER_SAMPLE_FILE=/samples/js-samples.json
# Sample files (outside of the Docker context):
GO_SAMPLE_FILE=./test_samples/go-samples.json
JS_SAMPLE_FILE=./test_samples/js-samples.json
# Generate test samples from all repositories:
docker run --mount $MOUNT $GO_CONTAINER generate $GO_CONTAINER_SAMPLE_FILE
if [ ! $? -eq 0 ]; then
exit 1
fi
docker run --mount $MOUNT $JS_CONTAINER generate $JS_CONTAINER_SAMPLE_FILE
if [ ! $? -eq 0 ]; then
exit 1
fi
# Verify files:
if [ ! -e $GO_SAMPLE_FILE ]; then
echo "go-samples.json is missing"
exit 1
fi
if [ ! -e $JS_SAMPLE_FILE ]; then
echo "js-samples.json is missing"
exit 1
fi
# Validate test samples:
echo "---------- Javascript ----------"
docker run --mount $MOUNT $JS_CONTAINER validate $GO_CONTAINER_SAMPLE_FILE
if [ ! $? -eq 0 ]; then
exit 1
fi
echo "--------------------"
echo "---------- Golang ----------"
docker run --mount $MOUNT $GO_CONTAINER validate $JS_CONTAINER_SAMPLE_FILE
if [ ! $? -eq 0 ]; then
exit 1
fi
echo "--------------------"