Skip to content
Snippets Groups Projects
Commit ca3ef6be authored by gbe's avatar gbe
Browse files

clean up test

parent 787fb0b8
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,8 @@ import ( ...@@ -8,7 +8,8 @@ import (
"testing" "testing"
"git.c3pb.de/gbe/invinoveritas/log" "git.c3pb.de/gbe/invinoveritas/log"
"git.c3pb.de/gbe/invinoveritas/vino" "git.c3pb.de/gbe/invinoveritas/storage"
"git.c3pb.de/gbe/invinoveritas/storage/query"
) )
type testLogger struct { type testLogger struct {
...@@ -20,24 +21,6 @@ func (tl testLogger) Log(vals ...interface{}) error { ...@@ -20,24 +21,6 @@ func (tl testLogger) Log(vals ...interface{}) error {
return nil return nil
} }
type dummyStorage struct{}
func (d dummyStorage) Store(ctx context.Context, v *vino.Vino) error {
return nil
}
func (d dummyStorage) StoreComment(ctx context.Context, v *vino.Vino, txt string) error {
return nil
}
func (d dummyStorage) DeleteComment(ctx context.Context, id int) error {
return nil
}
func (d dummyStorage) DeleteVino(ctx context.Context, id int) error {
return nil
}
func TestHandler_Index_Add(t *testing.T) { func TestHandler_Index_Add(t *testing.T) {
w := httptest.NewRecorder() w := httptest.NewRecorder()
...@@ -47,10 +30,18 @@ func TestHandler_Index_Add(t *testing.T) { ...@@ -47,10 +30,18 @@ func TestHandler_Index_Add(t *testing.T) {
r := httptest.NewRequest("POST", "/add", strings.NewReader(data.Encode())) r := httptest.NewRequest("POST", "/add", strings.NewReader(data.Encode()))
r.Header.Set("Content-Type", "application/x-www-form-urlencoded") r.Header.Set("Content-Type", "application/x-www-form-urlencoded")
var h Handler
logger := testLogger{t} logger := testLogger{t}
db, err := storage.Open(context.Background(), ":memory:", logger)
if err != nil {
t.Fatal("unexpected error:", err)
}
defer db.Close()
h := Handler{
Q: query.New(db),
}
hdlr := log.Request(h.index(), logger) hdlr := log.Request(h.index(), logger)
hdlr.ServeHTTP(w, r) hdlr.ServeHTTP(w, r)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment