123456789101112131415161718192021222324252627282930313233 |
- package nosql
- import (
- "context"
- "io/ioutil"
- "testing"
- "github.com/jackc/pgx/v5"
- )
- var (
- dbConn string
- )
- func init() {
- // read postgres connection string from file z_data.config
- connSource, _ := ioutil.ReadFile("z_data.config")
- dbConn = string(connSource)
- }
- func TestNoSQL(t *testing.T) {
- if db, err := pgx.Connect(context.Background(), dbConn); err == nil {
- ex := New(func(ctx context.Context) (pgx.Tx, error) {
- return db.Begin(ctx)
- })
- res, err := ex.Call(context.Background(), "public.arr_count", map[string]interface{}{
- "input": []int{0, 1, 2},
- })
- t.Log(res, err)
- } else {
- t.Error(err)
- }
- }
|