4
我想在GitLab.com上設置一個CI運行器,我想用它來運行需要PostgreSQL數據庫連接的測試。 CI + PostgreSQL的文檔似乎過於簡單,它似乎告訴一旦提供連接信息,數據庫設置完成。我可能會誤解文檔,因爲我無法創建數據庫。我gitlab-ci.yml
看起來像這樣在GitLab CI中設置PostgreSQL
image: node:latest
services:
- postgres:latest
variables:
POSTGRES_DB: rx_reactive_test
POSTGRES_USER: rx_reactive_tester
POSTGRES_PASSWORD: "1esdf3143"
cache:
paths:
- node_modules/
postgresql:
script:
- yarn install
- npm test
運行命令NPM test`,它將運行,將建立與數據庫的連接數的測試。但是,這些測試失敗,出現錯誤消息
pg-reactive
✓ should build connection with the test database.
1) should run a query returning one row.
1 passing (23ms)
1 failing
1) pg-reactive should run a query returning one row.:
Uncaught Error: connect ECONNREFUSED 127.0.0.1:5432
at Object.exports._errnoException (util.js:1033:11)
at exports._exceptionWithHostPort (util.js:1056:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1099:14)
這些測試與我的本地測試數據庫運行良好,所以必須有我的CI設置有問題。我將不勝感激任何關於我的問題的幫助:-)
嘿,謝謝你的回答,但它仍然有點模糊,所以它應該與以下連接設置一起使用? 'connection:{host:'postgres',user:'user',password:'test',port:5432,database:'withlove_test'}'? – javiercf