Skip to content

Commit

Permalink
add lightweight acceptance test harness
Browse files Browse the repository at this point in the history
  • Loading branch information
jbielick committed Dec 14, 2022
1 parent 4b3ee04 commit 5ec3148
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
25 changes: 25 additions & 0 deletions acceptance-test.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -euo pipefail

echo 'begin acceptance test suite'
find ./tests -mindepth 1 -type d | while read -r path; do
title="$(basename "$path")"
echo "$title"
mysql="mysql -h mysql -uroot -proot"
echo ' -> prepare'
$mysql -e "drop database if exists "'`'"$title"'`;'"create database "'`'"$title"'`;'
echo ' -> seed'
$mysql "$title" < "$path/setup.sql"
echo ' -> dumping'
if ! contents="$(go run . -hmysql -uroot -proot -c "$path/config.hcl")"; then
echo "$title"
continue
fi
echo ' -> importing'
if ! $mysql <<< "$contents"; then
echo "$title"
continue
fi
echo "$title"
done
3 changes: 3 additions & 0 deletions tests/0001-escaping/config.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
database "001" {
table "test" {}
}
5 changes: 5 additions & 0 deletions tests/0001-escaping/setup.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
create table `test` (
`col` json
);
INSERT INTO `test` (`col`) VALUES
('\"--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\\nkey1: value1\\nkey2: value2\\n\"');

0 comments on commit 5ec3148

Please sign in to comment.