-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add and improve tests #92
Conversation
61c598e
to
f411e79
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Execute queries with commands in the container * Remove `-p 33061:3306` from `container run` * Change the query result to check as it is * Add test for `mroonga_command('status')`
CI may take longer than 10 seconds.
f411e79
to
8c1c9f2
Compare
test.sh
Outdated
@@ -19,29 +19,54 @@ container_name="mroonga_build_test_${timestamp}" | |||
eval $(grep -E -o '[a-z]+_version=[0-9.]+' $context/Dockerfile) | |||
mysql_version=$(head -n1 $context/Dockerfile | grep -E -o '[0-9.]{2,}') | |||
|
|||
function run_sql() { | |||
sql=$1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sql=$1 | |
sql="$1" |
test.sh
Outdated
success=$? | ||
|
||
set -e | ||
sudo docker container stop $container_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
こいつらをtrap EXIT
でやるようにしたら↑の&&
はなくせる?
function cleanup() {
sudo docker container stop $container_name
sudo docker container logs $container_name
sudo docker container rm $container_name
}
trap cleanup EXIT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ぉぉ、これ探してたんですよ!試してみます。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
あざます。できました。
test.sh
Outdated
set +e | ||
diff -u /tmp/expected.txt /tmp/actual.txt | ||
echo -e "$(run_sql "SELECT JSON_PRETTY(mroonga_command('status'))")" && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo -e
ってなんで必要なの?\n
を改行にしたいとか?
echo -e "$(run_sql "SELECT JSON_PRETTY(mroonga_command('status'))")" && \ | |
run_sql "SELECT JSON_PRETTY(mroonga_command('status'))" && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そうですね。
echo
しないと {\n "os": "Linux",\n "cpu": "x86_64",\n ...
という感じだったので付けました。
そもそもこの表示がいらないか。
test.sh
Outdated
expected=$1 | ||
actual=$2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected=$1 | |
actual=$2 | |
expected="$1" | |
actual="$2" |
test.sh
Outdated
function assert() { | ||
expected=$1 | ||
actual=$2 | ||
if [ "$(echo ${expected})" = "$(echo ${actual})" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なんでecho
いるの?
if [ "$(echo ${expected})" = "$(echo ${actual})" ]; then | |
if [ "${expected}" = "${actual}" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo
いらないです。見た目が同じ文字列が =
判定されなくて色々検証していた残骸です…。
(=
判定されなかったのは \t
じゃなくて
(ただのスペース)だったからでした。)
-p 33061:3306
fromcontainer run
mroonga_command('status')