mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-19 05:55:19 +00:00
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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user