VILLASweb-backend-go/routes/config/config_test.go
2021-08-27 12:11:46 +02:00

48 lines
1.6 KiB
Go

/** Healthz package, testing.
*
* @author Steffen Vogel <svogel2@eonerc.rwth-aachen.de>
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* VILLASweb-backend-go
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
package config
import (
"net/http"
"testing"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/configuration"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/helper"
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/assert"
)
var router *gin.Engine
func TestConfig(t *testing.T) {
err := configuration.InitConfig()
assert.NoError(t, err)
router = gin.Default()
api := router.Group("/api/v2")
RegisterConfigEndpoint(api.Group("/config"))
code, resp, err := helper.TestEndpoint(router, "", "/api/v2/config", http.MethodGet, nil)
assert.NoError(t, err)
assert.Equalf(t, 200, code, "Response body: \n%v\n", resp)
}