#!/bin/bash # ------------------ # This is a test script that initializes a new project. # ------------------ set -e set -x PS4='+(${BASH_SOURCE}:${LINENO}): ' proj_root=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")/..") cd "$proj_root" # Compile `gas` gas="/tmp/gas" ops/compile.sh mv gas $gas test_project="/memory/test_gasproj" if [[ -e $test_project ]]; then rm -r "$test_project" fi $gas init "$test_project" < $proj_root" >> go.mod # Create a new table in the schema cat >> pkg/db/schema.sql < pkg/db/item.go $gas generate items --test > pkg/db/item_test.go go mod tidy # Run the tests go test ./... # Run sqlite_lint $gas sqlite_lint pkg/db/schema.sql # Notify success in green echo -e "\033[32mAll tests passed. Finished successfully.\033[0m"