diff --git a/test-files/test.avro b/test-files/test.avro new file mode 100644 index 0000000..95bec04 Binary files /dev/null and b/test-files/test.avro differ diff --git a/test-files/test.parquet b/test-files/test.parquet new file mode 100644 index 0000000..1aa8980 Binary files /dev/null and b/test-files/test.parquet differ diff --git a/test-files/test.protobuf.avro b/test-files/test.protobuf.avro new file mode 100644 index 0000000..bd591a2 Binary files /dev/null and b/test-files/test.protobuf.avro differ diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..2d03a6b --- /dev/null +++ b/test.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +set -euo pipefail + +if [ $# -ne 1 ]; then + echo "Usage: test.sh gs://temp/location" + exit 1 +fi + +GCS=$(mktemp --dry-run --tmpdir=$1 gcs-tools-XXXXXXXXXX) +echo "[INFO] GCS temporary location: $GCS" +OUT=$(mktemp --dry-run --tmpdir= gcs-tools-out-XXXXXXXXXX) +echo "[INFO] Local temporary file: $OUT" + +./make-binary.sh + +gsutil cp test-files/* $GCS + +die() { + echo "[FAIL] $*" + echo "============================================================" + cat $OUT + echo "============================================================" + cleanup + exit 1 +} + +cleanup() { + echo "[INFO] Cleaning up $OUT" + rm $OUT + echo "[INFO] Cleaning up $GCS" + gsutil rm -r "$GCS/*" +} + +test_cmd() { + match=$1 + shift + cmd=$* + echo "[TEST] $cmd" + $cmd > $OUT 2>&1 + grep -q "$match" $OUT || die "$cmd" + echo "[PASS] $cmd" +} + +echo "============================================================" + +test_cmd 'AvroTools' ./bin/avro-tools getschema $GCS/test.avro +test_cmd '"name":"user100"' ./bin/avro-tools tojson $GCS/test.avro + +test_cmd 'AvroTools' ./bin/parquet-cli schema $GCS/test.parquet +test_cmd 'AvroTools' ./bin/parquet-cli meta $GCS/test.parquet +test_cmd '"name": "user100"' ./bin/parquet-cli cat $GCS/test.parquet + +test_cmd 'ProtoTools' ./bin/proto-tools getschema $GCS/test.protobuf.avro +test_cmd '"name":"user100"' ./bin/proto-tools tojson $GCS/test.protobuf.avro + +test_cmd 'case class AvroTools' ./bin/magnolify-tools avro $GCS/test.avro +test_cmd 'case class AvroTools' ./bin/magnolify-tools parquet $GCS/test.parquet + +echo "============================================================" + +cleanup