Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
stork
Commits
6ce09c66
Commit
6ce09c66
authored
Sep 27, 2019
by
Tomek Mrugalski
🛰
Browse files
First unit-test developed
parent
bfdb9aac
Changes
3
Hide whitespace changes
Inline
Side-by-side
backend/stork.go
View file @
6ce09c66
...
...
@@ -7,12 +7,18 @@ import (
// Specifies Stork backend version.
const
VERSION
=
"0.0.1"
func
main
()
{
func
setupRouter
()
*
gin
.
Engine
{
r
:=
gin
.
Default
()
r
.
GET
(
"/version-get"
,
func
(
c
*
gin
.
Context
)
{
c
.
JSON
(
200
,
gin
.
H
{
"version"
:
VERSION
,
})
})
return
r
}
func
main
()
{
r
:=
setupRouter
()
r
.
Run
()
// listen and serve on 0.0.0.0:8080
}
backend/stork_test.go
0 → 100644
View file @
6ce09c66
package
main
import
(
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
)
// This test checks if version-get works and returns expected version string.
func
TestVersionGet
(
t
*
testing
.
T
)
{
const
exp_version
=
"0.0.1"
router
:=
setupRouter
()
w
:=
httptest
.
NewRecorder
()
req
,
_
:=
http
.
NewRequest
(
"GET"
,
"/version-get"
,
nil
)
router
.
ServeHTTP
(
w
,
req
)
// Make sure the http status code is 200
assert
.
Equal
(
t
,
http
.
StatusOK
,
w
.
Code
)
// Make sure the body contains version
assert
.
Equal
(
t
,
"{
\"
version
\"
:
\"
"
+
exp_version
+
"
\"
}
\n
"
,
w
.
Body
.
String
())
}
doc/devel.rst
0 → 100644
View file @
6ce09c66
.. _devel:
*****************
Developer's Guide
*****************
This part of the documentation pertains to some basic information intended to be used by developers.
Backend unit-tests
==================
We expect to have a very good test coverage for the code we produce, similar to what is there in
the Kea project. Each file whatever.go is supposed to be accompanied with whatever_test.go.
To run such unit-test, please use:
.. code-block:: console
go test
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment