SimpleCloudNotifier/server/test/webserver_test.go

46 lines
1.0 KiB
Go
Raw Normal View History

2022-11-23 20:21:49 +01:00
package test
import (
tt "blackforestbytes.com/simplecloudnotifier/test/util"
2022-11-30 10:35:05 +01:00
"fmt"
2022-11-23 20:21:49 +01:00
"testing"
)
func TestWebserver(t *testing.T) {
ws, stop := tt.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) {
ws, stop := tt.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
_ = tt.RequestGet[tt.Void](t, baseUrl, "/api/ping")
_ = tt.RequestPut[tt.Void](t, baseUrl, "/api/ping", nil)
_ = tt.RequestPost[tt.Void](t, baseUrl, "/api/ping", nil)
_ = tt.RequestPatch[tt.Void](t, baseUrl, "/api/ping", nil)
_ = tt.RequestDelete[tt.Void](t, baseUrl, "/api/ping", nil)
2022-11-24 12:53:27 +01:00
}
func TestMongo(t *testing.T) {
ws, stop := tt.StartSimpleWebserver(t)
2022-11-24 12:53:27 +01:00
defer stop()
baseUrl := "http://127.0.0.1:" + ws.Port
_ = tt.RequestPost[tt.Void](t, baseUrl, "/api/db-test", nil)
2022-11-24 12:53:27 +01:00
}
func TestHealth(t *testing.T) {
ws, stop := tt.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
_ = tt.RequestGet[tt.Void](t, baseUrl, "/api/health")
2022-11-23 20:21:49 +01:00
}