Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cloudProject
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Job Bahner
cloudProject
Commits
ddcefa86
Commit
ddcefa86
authored
5 years ago
by
jobnestor
Browse files
Options
Downloads
Patches
Plain Diff
Added test for GET in reviews
parent
ecf2d7c5
No related branches found
No related tags found
1 merge request
!4
Finished app
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
reviews_test.go
+47
-0
47 additions, 0 deletions
reviews_test.go
with
47 additions
and
0 deletions
reviews_test.go
0 → 100644
+
47
−
0
View file @
ddcefa86
package
cloudproject
import
(
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
)
func
TestReviewHandleGet
(
t
*
testing
.
T
)
{
// Need to set up DB so statushandler can test connectivity
const
projectID
=
"altocumulus-5c3b3"
const
reviews
=
"reviews"
DB
=
FirestoreDatabase
{
ProjectID
:
projectID
,
CollectionName
:
reviews
}
err
:=
DB
.
Init
()
if
err
!=
nil
{
t
.
Error
(
err
)
}
defer
DB
.
Close
()
// make new request to status handler
req
,
err
:=
http
.
NewRequest
(
"GET"
,
"/review"
,
nil
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
rr
:=
httptest
.
NewRecorder
()
// check if response is 200
if
status
:=
rr
.
Code
;
status
!=
http
.
StatusOK
{
t
.
Errorf
(
"handler returned wrong status code: got %v want %v"
,
status
,
http
.
StatusOK
)
}
handler
:=
http
.
HandlerFunc
(
StatusHandler
)
handler
.
ServeHTTP
(
rr
,
req
)
// Check the response body is what we expect.
var
expected
=
Review
{}
response
:=
rr
.
Body
.
String
()
err
=
json
.
NewDecoder
(
rr
.
Body
)
.
Decode
(
&
expected
)
if
err
!=
nil
{
t
.
Errorf
(
"Handler returned an invalid json format: %s"
,
response
)
}
}
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