本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.0KB

  1. #!/bin/bash
  2. DOCKER_IP=${DOCKER_IP:-127.0.0.1}
  3. sqlite3() {
  4. DATABASE_URI="sqlite3://file:dummy?mode=memory&cache=shared" go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic
  5. return $?
  6. }
  7. postgres10() {
  8. ID=$(docker run -p 5432 -d postgres:10-alpine)
  9. PORT=$(docker port "$ID" 5432 | cut -d : -f 2)
  10. DATABASE_URI="postgres://user=postgres password=postgres dbname=postgres host=$DOCKER_IP port=$PORT sslmode=disable" go test -v -race -cover
  11. S=$?
  12. docker rm -vf "$ID" > /dev/null
  13. return $S
  14. }
  15. postgres96() {
  16. ID=$(docker run -p 5432 -d postgres:9.6-alpine)
  17. PORT=$(docker port "$ID" 5432 | cut -d : -f 2)
  18. DATABASE_URI="postgres://user=postgres password=postgres dbname=postgres host=$DOCKER_IP port=$PORT sslmode=disable" go test -v -race -cover
  19. S=$?
  20. docker rm -vf "$ID" > /dev/null
  21. return $S
  22. }
  23. postgres94() {
  24. ID=$(docker run -p 5432 -d postgres:9.4-alpine)
  25. PORT=$(docker port "$ID" 5432 | cut -d : -f 2)
  26. DATABASE_URI="postgres://user=postgres password=postgres dbname=postgres host=$DOCKER_IP port=$PORT sslmode=disable" go test -v -race -cover
  27. S=$?
  28. docker rm -vf "$ID" > /dev/null
  29. return $S
  30. }
  31. mysql57() {
  32. ID=$(docker run \
  33. -e MYSQL_ROOT_PASSWORD=root \
  34. -e MYSQL_USER=mysql \
  35. -e MYSQL_PASSWORD=mysql \
  36. -e MYSQL_DATABASE=mysql \
  37. -p 3306 -d mysql:5.7)
  38. PORT=$(docker port "$ID" 3306 | cut -d : -f 2)
  39. DATABASE_URI="mysql://mysql:mysql@tcp($DOCKER_IP:$PORT)/mysql?charset=utf8&parseTime=True" go test -v -race -cover
  40. S=$?
  41. docker rm -vf "$ID" > /dev/null
  42. return $S
  43. }
  44. mariadb10() {
  45. ID=$(docker run \
  46. -e MYSQL_ROOT_PASSWORD=root \
  47. -e MYSQL_USER=mysql \
  48. -e MYSQL_PASSWORD=mysql \
  49. -e MYSQL_DATABASE=mysql \
  50. -p 3306 -d mariadb:10)
  51. PORT=$(docker port "$ID" 3306 | cut -d : -f 2)
  52. DATABASE_URI="mysql://mysql:mysql@tcp($DOCKER_IP:$PORT)/mysql?charset=utf8&parseTime=True" go test -v -race -cover
  53. S=$?
  54. docker rm -vf "$ID" > /dev/null
  55. return $S
  56. }
  57. sqlite3 || exit 1
  58. postgres94 || exit 1
  59. postgres96 || exit 1
  60. postgres10 || exit 1
  61. mysql57 || exit 1
  62. mariadb10 || exit 1
上海开阖软件有限公司 沪ICP备12045867号-1