Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 在Travis中针对多个数据库测试ActiveRecord(没有虚拟rails应用程序)_Mysql_Ruby On Rails_Postgresql_Rails Activerecord_Travis Ci - Fatal编程技术网

Mysql 在Travis中针对多个数据库测试ActiveRecord(没有虚拟rails应用程序)

Mysql 在Travis中针对多个数据库测试ActiveRecord(没有虚拟rails应用程序),mysql,ruby-on-rails,postgresql,rails-activerecord,travis-ci,Mysql,Ruby On Rails,Postgresql,Rails Activerecord,Travis Ci,我目前正致力于设置库的activerecord\u any\u,以使用TravisCI跨多种数据库类型进行自动测试 目前我有以下几点: 在.travis.yml中 language: ruby script: - bundle exec rake test before_script: - mysql -e 'create database activerecord_any_of_test;' - psql -c 'create database activerecord_any_o

我目前正致力于设置
库的
activerecord\u any\u,以使用TravisCI跨多种数据库类型进行自动测试

目前我有以下几点:

.travis.yml中

language: ruby
script:
  - bundle exec rake test
before_script:
  - mysql -e 'create database activerecord_any_of_test;'
  - psql -c 'create database activerecord_any_of_test;' -U postgres
before_install:
  - gem install bundler # use the latest bundler, since Travis doesn't update for us
rvm:
  - 1.9.3
  - 2.0.0
  - 2.1.1
  - rbx
  - jruby-19mode
env:
  - DB=mysql
  - DB=sqlite3
  - DB=sqlite3mem
  - DB=postgresql
gemfile:
  - gemfiles/rails3.gemfile
  - gemfiles/rails4.gemfile
  - gemfiles/rails_edge.gemfile
matrix:
  allow_failures:
    - gemfile: gemfiles/rails_edge.gemfile
    - env: DB=postgresql
    - env: DB=mysql
数据库.yml

sqlite3:
  adapter: <%= "jdbc" if defined? JRUBY_VERSION %>sqlite3
  database: activerecord_any_of.sqlite3.db
sqlite3mem:
  adapter: <%= "jdbc" if defined? JRUBY_VERSION %>sqlite3
  database: ":memory:"
postgresql:
  adapter: postgresql
  encoding: unicode
  database: activerecord_any_of_test
  pool: 5
  username: postgres
  password:
  min_messages: warning
mysql:
  adapter: <%= defined?(JRUBY_VERSION) ? "jdbcmysql" : "mysql2" %>
  host: localhost
  username: root
  password:
  database: activerecord_any_of_test
  encoding: utf8
## Add DB Configuration to run Oracle tests
oracle:
  adapter: oracle_enhanced
  host: localhost
  username: activerecord_any_of_dev
  password:
  database: xe
当我在TravisCI上运行测试时,在大多数情况下,
sqlite
sqlitemem
矩阵运行得很好。但是,在运行MySQL时,我会遇到以下错误:

Mysql2::Error: Unknown database activerecord_any_of_test
在运行PostgreSQL时,我得到一个错误:

ActiveRecord::StatementInvalid: PG::ConnectionBad: connection is closed: ROLLBACK
因为我正在创建数据库,我不明白为什么会有任何问题。据我所知,我已经将
数据库.yml
配置为使用正确的凭据。也许我使用的是
Combustion::Database
错误?如何在测试中正确连接到数据库

我已经调整了中用于设置测试的设置。可以在特拉维斯身上看到

ActiveRecord::StatementInvalid: PG::ConnectionBad: connection is closed: ROLLBACK