Skip to content

intg-test: print configPath contents #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions integrationtests/hotload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package integrationtests
import (
"database/sql"
"fmt"
"io/ioutil"
"log"
"os"
"time"

"github.com/infobloxopen/hotload"
Expand All @@ -28,7 +28,7 @@ func init() {
}

func setDSN(dsn string, path string) {
err := ioutil.WriteFile(path, []byte(dsn), 777)
err := os.WriteFile(path, []byte(dsn), 777)
if err != nil {
Fail("error writing dsn file")
}
Expand Down Expand Up @@ -89,6 +89,7 @@ var _ = Describe("hotload integration tests", func() {
)

BeforeEach(func() {
log.Println("BeforeEach")
setDSN(hotloadTestDsn, configPath)
hltDb = openDb(hotloadTestDsn)
hlt1Db = openDb(hotloadTest1Dsn)
Expand All @@ -107,6 +108,12 @@ var _ = Describe("hotload integration tests", func() {

It("should connect to new db when file changes", func() {
for i := 0; i < 2; i++ {
configDsn, err := os.ReadFile(configPath)
if err != nil {
Fail(fmt.Sprintf("ReadFile(%s) error opening db: %v", configPath, err))
}
log.Println(fmt.Sprintf("ReadFile(%s)=`%s`", configPath, string(configDsn)))

r, err := db.Exec(fmt.Sprintf("INSERT INTO test (c1) VALUES (%d)", i))
if err != nil {
Fail(fmt.Sprintf("error inserting row: %v", err))
Expand Down