little things all tested
parent
6ba23e61c3
commit
02fecb7eb2
4
queue.go
4
queue.go
|
|
@ -11,10 +11,6 @@ type Queue struct {
|
|||
driver Driver
|
||||
}
|
||||
|
||||
func NewTestQueueIn(d string) Queue {
|
||||
return Queue{driver: NewTestDBIn(d)}
|
||||
}
|
||||
|
||||
func NewQueue(driver Driver) Queue {
|
||||
return Queue{driver: driver}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,10 +13,6 @@ type Storage struct {
|
|||
driver Driver
|
||||
}
|
||||
|
||||
func NewTestStorageIn(d string) Storage {
|
||||
return Storage{driver: NewTestDBIn(d)}
|
||||
}
|
||||
|
||||
func NewStorage(driver Driver) Storage {
|
||||
return Storage{driver: driver}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,36 @@
|
|||
package main
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestStorage(t *testing.T) {
|
||||
ctx, can := context.WithTimeout(context.Background(), time.Second)
|
||||
defer can()
|
||||
|
||||
db := NewTestDBIn(t.TempDir())
|
||||
defer db.Close()
|
||||
|
||||
s := NewStorage(db)
|
||||
|
||||
if _, err := s.Get(ctx, "id"); err != ErrNotFound {
|
||||
t.Error("failed to get 404", err)
|
||||
}
|
||||
|
||||
m := Message{
|
||||
ID: "id",
|
||||
TS: 1,
|
||||
}
|
||||
|
||||
if err := s.Upsert(ctx, m); err != nil {
|
||||
t.Error("failed to upsert", err)
|
||||
}
|
||||
|
||||
if m2, err := s.Get(ctx, "id"); err != nil {
|
||||
t.Error("failed to get", err)
|
||||
} else if m != m2 {
|
||||
t.Error(m2)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue