SimpleCloudNotifier/server/test/webserver_test.go

45 lines
929 B
Go
Raw Normal View History

2022-11-23 20:21:49 +01:00
package test
import (
2022-11-30 10:35:05 +01:00
"fmt"
2022-11-23 20:21:49 +01:00
"testing"
)
func TestWebserver(t *testing.T) {
2022-11-30 10:35:05 +01:00
ws, stop := StartSimpleWebserver(t)
2022-11-24 12:53:27 +01:00
defer stop()
2022-11-30 10:35:05 +01:00
fmt.Printf("Port := %s\n", ws.Port)
2022-11-23 20:21:49 +01:00
}
func TestPing(t *testing.T) {
2022-11-30 10:35:05 +01:00
ws, stop := StartSimpleWebserver(t)
2022-11-24 12:53:27 +01:00
defer stop()
2022-11-23 20:21:49 +01:00
baseUrl := "http://127.0.0.1:" + ws.Port
2022-11-30 10:35:05 +01:00
_ = requestGet[Void](t, baseUrl, "/api/ping")
_ = requestPut[Void](t, baseUrl, "/api/ping", nil)
_ = requestPost[Void](t, baseUrl, "/api/ping", nil)
_ = requestPatch[Void](t, baseUrl, "/api/ping", nil)
_ = requestDelete[Void](t, baseUrl, "/api/ping", nil)
2022-11-24 12:53:27 +01:00
}
func TestMongo(t *testing.T) {
2022-11-30 10:35:05 +01:00
ws, stop := StartSimpleWebserver(t)
2022-11-24 12:53:27 +01:00
defer stop()
baseUrl := "http://127.0.0.1:" + ws.Port
2022-11-30 10:35:05 +01:00
_ = requestPost[Void](t, baseUrl, "/api/db-test", nil)
2022-11-24 12:53:27 +01:00
}
func TestHealth(t *testing.T) {
2022-11-30 10:35:05 +01:00
ws, stop := StartSimpleWebserver(t)
2022-11-24 12:53:27 +01:00
defer stop()
baseUrl := "http://127.0.0.1:" + ws.Port
2022-11-23 20:21:49 +01:00
2022-11-30 10:35:05 +01:00
_ = requestGet[Void](t, baseUrl, "/api/health")
2022-11-23 20:21:49 +01:00
}