gpt4 book ai didi

node.js - 创建后 Postgresql 数据库在 travis ci 中不存在

转载 作者:行者123 更新时间:2023-11-29 13:43:49 25 4
gpt4 key购买 nike

将 postgresql 添加到我的应用程序后,每次我在 travis 上运行测试时,我都会收到一条错误消息,指出当我在 travis.yml 中运行 database.js 时,数据库不存在。但我的测试在本地通过这是我的 .yml 文件

services:
- postgresql
before_script:
- travis_wait 30 yarn install
- "psql -c 'create database myDiary;' -U postgres"
- travis_wait npm install
- node build/models/database.js

这是我在 database.js 中的连接

const connectionString = 'postgres://postgres:password@localhost:5432/myDiary';

const client = new pg.Client(connectionString);
client.connect();

附件是我的travis输出

Travis CI 错误输出

enter image description here

最佳答案

Travis 没有创建 myDiary 数据库,因为整行都被字符串化了。只有 -c 后面的命令应该是一个字符串。

services:
- postgresql
before_script:
- travis_wait 30 yarn install
- psql -c 'create database myDiary;' -U postgres
- travis_wait npm install
- node build/models/database.js

关于node.js - 创建后 Postgresql 数据库在 travis ci 中不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51569499/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com