Commit 6ce09c66 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

First unit-test developed

parent bfdb9aac
......@@ -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
package main
import (
// 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())
.. _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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment