From 1c410e90d99c724f56dfda40c2e3cc906b55ffa2 Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Thu, 19 Jan 2023 11:18:23 +0200 Subject: [PATCH] feat(sdbapi): initial testing --- sdbapi/main_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 sdbapi/main_test.go diff --git a/sdbapi/main_test.go b/sdbapi/main_test.go new file mode 100644 index 0000000..9e992e0 --- /dev/null +++ b/sdbapi/main_test.go @@ -0,0 +1,30 @@ +/* + * This file is part of sdbapi + * Copyright (C) 2022 Jonni Liljamo + * + * Licensed under GPL-3.0-only. + * See LICENSE for licensing information. + */ + +package main + +import ( + "net/http" + "net/http/httptest" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestMiscInfo(t *testing.T) { + r := createRouter() + + w := httptest.NewRecorder() + req, _ := http.NewRequest("GET", "/api/info", nil) + r.ServeHTTP(w, req) + + expected := "{\"info\":\"Deck Builder API\",\"ver\":\"0.0.1\"}" + + assert.Equal(t, http.StatusOK, w.Code) + assert.Equal(t, expected, w.Body.String()) +} -- 2.44.1