Buddy Works无法使用postgres数据库运行Laravel单元测试

时间:2018-12-22 20:51:29

标签: laravel postgresql continuous-integration

我正在开发Laravel应用程序。现在,我正在https://buddy.works/上为我的应用程序设置持续集成。我的应用程序正在使用Postgres。

这是我在Buddy上的phpunit操作配置

enter image description here

我也为Postgres添加了一项服务。

enter image description here

这是我在.env.buddy中的数据库设置

DB_CONNECTION=pgsql
DB_HOST=db
DB_PORT=5432
DB_DATABASE=easy_eat
DB_USERNAME=easy_eat
DB_PASSWORD=secret

那里的数据库名称为easy_eat。但是对于测试,我使用了不同的数据库名称。我在config / database.php中配置了它。

     'test' => [
        'driver' => 'pgsql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '5432'),
        'database' => 'test',
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'charset' => 'utf8',
        'prefix' => '',
        'prefix_indexes' => true,
        'schema' => 'public',
        'sslmode' => 'prefer',
    ],

当我推送代码并运行管道时,出现此错误。

There was 1 error:
1) Tests\Unit\ExampleTest::testBasicTest
Illuminate\Database\QueryException: could not find driver (SQL: select tablename from pg_catalog.pg_tables where schemaname = 'public')
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:333
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Schema/PostgresBuilder.php:86
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Schema/PostgresBuilder.php:35
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/FreshCommand.php:73
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/FreshCommand.php:46
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Container/Container.php:572
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Console/Command.php:183
/buddy/easy-eat-backend-laravel/vendor/symfony/console/Command/Command.php:255
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Console/Command.php:170
/buddy/easy-eat-backend-laravel/vendor/symfony/console/Application.php:901
/buddy/easy-eat-backend-laravel/vendor/symfony/console/Application.php:262
/buddy/easy-eat-backend-laravel/vendor/symfony/console/Application.php:145
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Console/Application.php:89
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Console/Application.php:188
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:250
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/PendingCommand.php:136
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/PendingCommand.php:218
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php:55
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:55
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:18
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:104
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:71
Caused by
Doctrine\DBAL\Driver\PDOException: could not find driver
/buddy/easy-eat-backend-laravel/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:67
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:46
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connectors/PostgresConnector.php:33
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php:182
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:918
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:943
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:399
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:325
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:657
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:333
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Schema/PostgresBuilder.php:86
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Schema/PostgresBuilder.php:35
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/FreshCommand.php:73
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/FreshCommand.php:46
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Container/Container.php:572
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Console/Command.php:183
/buddy/easy-eat-backend-laravel/vendor/symfony/console/Command/Command.php:255
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Console/Command.php:170
/buddy/easy-eat-backend-laravel/vendor/symfony/console/Application.php:901
/buddy/easy-eat-backend-laravel/vendor/symfony/console/Application.php:262
/buddy/easy-eat-backend-laravel/vendor/symfony/console/Application.php:145
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Console/Application.php:89
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Console/Application.php:188
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:250
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/PendingCommand.php:136
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/PendingCommand.php:218
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php:55
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:55
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:18
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:104
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:71
Caused by
PDOException: could not find driver
/buddy/easy-eat-backend-laravel/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:67
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:46
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connectors/PostgresConnector.php:33
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php:182
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:918
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:943
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:399
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:325
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:657
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:333
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Schema/PostgresBuilder.php:86
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Schema/PostgresBuilder.php:35
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/FreshCommand.php:73
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/FreshCommand.php:46
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Container/Container.php:572
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Console/Command.php:183
/buddy/easy-eat-backend-laravel/vendor/symfony/console/Command/Command.php:255
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Console/Command.php:170
/buddy/easy-eat-backend-laravel/vendor/symfony/console/Application.php:901
/buddy/easy-eat-backend-laravel/vendor/symfony/console/Application.php:262
/buddy/easy-eat-backend-laravel/vendor/symfony/console/Application.php:145
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Console/Application.php:89
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Console/Application.php:188
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:250
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/PendingCommand.php:136
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/PendingCommand.php:218
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php:55
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:55
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:18
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:104
/buddy/easy-eat-backend-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:71
ERRORS!
Tests: 2, Assertions: 1, Errors: 1.

我可以在本地运行测试。这是工作。但是在Buddy上,似乎无法连接到postgres数据库。我的设置有什么问题,我该如何解决?

0 个答案:

没有答案