mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-13 03:25:32 +00:00
convert seen service to use store
This commit is contained in:
@@ -2,13 +2,13 @@ package handler_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/micro/micro/v3/service/auth"
|
||||
"github.com/micro/micro/v3/service/store"
|
||||
"github.com/micro/micro/v3/service/store/memory"
|
||||
"github.com/micro/services/seen/handler"
|
||||
pb "github.com/micro/services/seen/proto"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -16,24 +16,8 @@ import (
|
||||
)
|
||||
|
||||
func testHandler(t *testing.T) *handler.Seen {
|
||||
// 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_seen_instances CASCADE"); err != nil {
|
||||
t.Fatalf("Error cleaning database: %v", err)
|
||||
}
|
||||
|
||||
h := &handler.Seen{}
|
||||
h.DBConn(sqlDB).Migrations(&handler.SeenInstance{})
|
||||
return h
|
||||
store.DefaultStore = memory.NewStore()
|
||||
return &handler.Seen{}
|
||||
}
|
||||
|
||||
func TestSet(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user