aboutsummaryrefslogtreecommitdiff
path: root/tests/functional
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-10-27 07:40:51 -0300
committerEuAndreh <eu@euandre.org>2024-10-27 07:40:51 -0300
commitf637c04d24bbb3a1f6bbd64180de55fa1aee44e2 (patch)
tree5c578ddfdd5af4cfc9df5823a9d1faa93f207e35 /tests/functional
parentMakefile: Simplify output generation of "bench" target dependencies (diff)
downloadfiinha-f637c04d24bbb3a1f6bbd64180de55fa1aee44e2.tar.gz
fiinha-f637c04d24bbb3a1f6bbd64180de55fa1aee44e2.tar.xz
src/q.go: New() - manage *sql.DB handle internally
Diffstat (limited to 'tests/functional')
-rw-r--r--tests/functional/consumer-with-deadletter/q.go8
-rw-r--r--tests/functional/new-instance-takeover/q.go21
-rw-r--r--tests/functional/wait-after-publish/q.go8
3 files changed, 9 insertions, 28 deletions
diff --git a/tests/functional/consumer-with-deadletter/q.go b/tests/functional/consumer-with-deadletter/q.go
index 44bc90b..25391c5 100644
--- a/tests/functional/consumer-with-deadletter/q.go
+++ b/tests/functional/consumer-with-deadletter/q.go
@@ -1,12 +1,10 @@
package q
import (
- "database/sql"
"errors"
"os"
"runtime"
- "golite"
"guuid"
g "gobang"
)
@@ -50,11 +48,7 @@ func MainTest() {
os.Remove(databasePath + "-shm")
os.Remove(databasePath + "-wal")
- db, err := sql.Open(golite.DriverName, databasePath)
- g.TErrorIf(err)
- defer db.Close()
-
- queue, err := New(db)
+ queue, err := New(databasePath)
g.TErrorIf(err)
defer queue.Close()
diff --git a/tests/functional/new-instance-takeover/q.go b/tests/functional/new-instance-takeover/q.go
index 10c4744..6e04e5f 100644
--- a/tests/functional/new-instance-takeover/q.go
+++ b/tests/functional/new-instance-takeover/q.go
@@ -1,12 +1,10 @@
package q
import (
-"fmt"
- "database/sql"
+ "fmt"
"runtime"
"os"
- "golite"
"guuid"
g "gobang"
)
@@ -38,16 +36,13 @@ func startInstance(
databasePath string,
instanceID int,
name string,
-) (*sql.DB, IQueue, error) {
- db, err := sql.Open(golite.DriverName, databasePath)
- g.TErrorIf(err)
-
- iqueue, err := New(db)
+) (IQueue, error) {
+ iqueue, err := New(databasePath)
g.TErrorIf(err)
queue := iqueue.(queueT)
notifyFn := makeNotifyFn(queue.subscriptions.read, queue.pinger)
- queries, err := initDB(db, defaultPrefix, notifyFn, instanceID)
+ queries, err := initDB(queue.db, defaultPrefix, notifyFn, instanceID)
g.TErrorIf(err)
err = queue.queries.close()
@@ -67,7 +62,7 @@ func startInstance(
queue.Subscribe(topic, individual, handlerFn(pub_(individual)))
queue.Subscribe(topic, shared, handlerFn(pub_(shared + "-" + name)))
- return db, queue, nil
+ return queue, nil
}
@@ -98,9 +93,8 @@ func MainTest() {
fmt.Fprintf(os.Stderr, "(PID %d + 1) ", instanceID1)
}
- db, q1, err := startInstance(dbpath, instanceID1, "first")
+ q1, err := startInstance(dbpath, instanceID1, "first")
g.TErrorIf(err)
- defer db.Close()
defer q1.Close()
pub(q1, topic, guuid.New())
@@ -111,9 +105,8 @@ func MainTest() {
<- q1.WaitFor( "shared-first", flowID1, "w").Channel
// println("waited 1")
- db, q2, err := startInstance(dbpath, instanceID2, "second")
+ q2, err := startInstance(dbpath, instanceID2, "second")
g.TErrorIf(err)
- defer db.Close()
defer q2.Close()
<- q2.WaitFor("individual-second", flowID1, "w").Channel
diff --git a/tests/functional/wait-after-publish/q.go b/tests/functional/wait-after-publish/q.go
index d3426ae..15a532d 100644
--- a/tests/functional/wait-after-publish/q.go
+++ b/tests/functional/wait-after-publish/q.go
@@ -1,11 +1,9 @@
package q
import (
- "database/sql"
"os"
"runtime"
- "golite"
"guuid"
g "gobang"
)
@@ -25,11 +23,7 @@ func MainTest() {
os.Remove(databasePath + "-shm")
os.Remove(databasePath + "-wal")
- db, err := sql.Open(golite.DriverName, databasePath)
- g.TErrorIf(err)
- defer db.Close()
-
- queue, err := New(db)
+ queue, err := New(databasePath)
g.TErrorIf(err)
defer queue.Close()