Streams tenancy (#91)

* fixup streams stuff

* use cache instead of pg in streams

* hash out issuer streams test

* fix compile error
This commit is contained in:
Asim Aslam
2021-05-01 22:34:35 +01:00
committed by GitHub
parent 500acefe47
commit b8877f8312
8 changed files with 87 additions and 82 deletions

View File

@@ -1,38 +1,23 @@
package handler_test
import (
"database/sql"
"os"
"testing"
"time"
"github.com/micro/micro/v3/service/events"
"github.com/micro/micro/v3/service/store/memory"
"github.com/micro/services/pkg/cache"
"github.com/micro/services/streams/handler"
)
func testHandler(t *testing.T) *handler.Streams {
// connect to the database
addr := os.Getenv("POSTGRES_URL")
if len(addr) == 0 {
addr = "postgresql://postgres@localhost:5432/postgres?sslmode=disable"
}
sqlDB, err := sql.Open("pgx", addr)
if err != nil {
t.Fatalf("Failed to open connection to DB %s", err)
}
// clean any data from a previous run
if _, err := sqlDB.Exec("DROP TABLE IF EXISTS micro_users, micro_tokens CASCADE"); err != nil {
t.Fatalf("Error cleaning database: %v", err)
}
h := &handler.Streams{
Cache: cache.New(memory.NewStore()),
Events: new(eventsMock),
Time: func() time.Time {
return time.Unix(1612787045, 0)
},
}
h.DBConn(sqlDB).Migrations(&handler.Token{})
return h
}