Skip to content

Commit 5ec3148

Browse files
committed
add lightweight acceptance test harness
1 parent 4b3ee04 commit 5ec3148

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

acceptance-test.bash

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
echo 'begin acceptance test suite'
6+
find ./tests -mindepth 1 -type d | while read -r path; do
7+
title="$(basename "$path")"
8+
echo "$title"
9+
mysql="mysql -h mysql -uroot -proot"
10+
echo ' -> prepare'
11+
$mysql -e "drop database if exists "'`'"$title"'`;'"create database "'`'"$title"'`;'
12+
echo ' -> seed'
13+
$mysql "$title" < "$path/setup.sql"
14+
echo ' -> dumping'
15+
if ! contents="$(go run . -hmysql -uroot -proot -c "$path/config.hcl")"; then
16+
echo "$title"
17+
continue
18+
fi
19+
echo ' -> importing'
20+
if ! $mysql <<< "$contents"; then
21+
echo "$title"
22+
continue
23+
fi
24+
echo "$title"
25+
done

tests/0001-escaping/config.hcl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
database "001" {
2+
table "test" {}
3+
}

tests/0001-escaping/setup.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
create table `test` (
2+
`col` json
3+
);
4+
INSERT INTO `test` (`col`) VALUES
5+
('\"--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\\nkey1: value1\\nkey2: value2\\n\"');

0 commit comments

Comments
 (0)