Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
invinoveritas
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gbe
invinoveritas
Commits
ca3ef6be
Commit
ca3ef6be
authored
3 years ago
by
gbe
Browse files
Options
Downloads
Patches
Plain Diff
clean up test
parent
787fb0b8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
handler-index_test.go
+12
-21
12 additions, 21 deletions
handler-index_test.go
with
12 additions
and
21 deletions
handler-index_test.go
+
12
−
21
View file @
ca3ef6be
...
...
@@ -8,7 +8,8 @@ import (
"testing"
"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
{
...
...
@@ -20,24 +21,6 @@ func (tl testLogger) Log(vals ...interface{}) error {
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
)
{
w
:=
httptest
.
NewRecorder
()
...
...
@@ -47,10 +30,18 @@ func TestHandler_Index_Add(t *testing.T) {
r
:=
httptest
.
NewRequest
(
"POST"
,
"/add"
,
strings
.
NewReader
(
data
.
Encode
()))
r
.
Header
.
Set
(
"Content-Type"
,
"application/x-www-form-urlencoded"
)
var
h
Handler
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
.
ServeHTTP
(
w
,
r
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment