Skip to content

Commit 3130f36

Browse files
committed
fix postgres in ci
1 parent 4ee2882 commit 3130f36

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

.github/workflows/test.yml

+21
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,31 @@ jobs:
1111
go-version:
1212
- 1.20.x
1313
os: [ubuntu-latest]
14+
services:
15+
postgres:
16+
image: postgres
17+
env:
18+
POSTGRES_PASSWORD: postgres
19+
options: >-
20+
--health-cmd pg_isready
21+
--health-interval 10s
22+
--health-timeout 5s
23+
--health-retries 5
24+
ports:
25+
- 5432:5432
1426
runs-on: ubuntu-latest
1527
steps:
1628
- name: Checkout code
1729
uses: actions/checkout@v3
1830
with:
1931
fetch-depth: 0
32+
- name: Setup Postgres
33+
uses: ikalnytskyi/action-setup-postgres@v4
34+
with:
35+
username: postgres
36+
password: postgres
37+
database: oui
38+
port: 5432
2039

2140
- name: Go Setup
2241
uses: actions/setup-go@v4
@@ -25,3 +44,5 @@ jobs:
2544

2645
- name: Run Tests
2746
run: go test -v ./...
47+
env:
48+
POSTGRES_PASSWORD: postgres

oui/db_test.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package oui_test
22

33
import (
4+
"fmt"
5+
"os"
46
"path/filepath"
57
"testing"
68

@@ -14,9 +16,12 @@ func Test_New(t *testing.T) {
1416
prefix := "00:50:56:00:00:00/24"
1517
org := "VMware, Inc."
1618
registry := "MA-L"
19+
1720
t.Run("postgres", func(t *testing.T) {
1821
t.Parallel()
19-
cs := "postgresql://oui:J5brHrAXFLQSif0K@localhost/oui?sslmode=disable"
22+
password := os.Getenv("POSTGRES_PASSWORD")
23+
require.NotEqual(t, "", password)
24+
cs := fmt.Sprintf("postgresql://oui:%s@localhost/oui", password)
2025
psql, err := oui.CreatePostgresOption(cs)
2126
require.NoError(t, err)
2227
ouidb, err := oui.New(oui.WithVersion("test"), psql)

0 commit comments

Comments
 (0)