SimpleCloudNotifier/scnserver/test/webserver_test.go

40 lines
942 B
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) {
2022-12-14 17:02:18 +01:00
_, baseUrl, stop := tt.StartSimpleWebserver(t)
2022-11-24 12:53:27 +01:00
defer stop()
2022-11-30 10:35:05 +01:00
2022-12-14 17:02:18 +01:00
fmt.Printf("URL := %s\n", baseUrl)
2022-11-23 20:21:49 +01:00
}
func TestPing(t *testing.T) {
2022-12-14 17:02:18 +01:00
_, baseUrl, stop := tt.StartSimpleWebserver(t)
2022-11-24 12:53:27 +01:00
defer stop()
2022-11-23 20:21:49 +01:00
_ = 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) {
2022-12-14 17:02:18 +01:00
_, baseUrl, stop := tt.StartSimpleWebserver(t)
2022-11-24 12:53:27 +01:00
defer stop()
_ = tt.RequestPost[tt.Void](t, baseUrl, "/api/db-test", nil)
2022-11-24 12:53:27 +01:00
}
func TestHealth(t *testing.T) {
2022-12-14 17:02:18 +01:00
_, baseUrl, stop := tt.StartSimpleWebserver(t)
2022-11-24 12:53:27 +01:00
defer stop()
_ = tt.RequestGet[tt.Void](t, baseUrl, "/api/health")
2022-11-23 20:21:49 +01:00
}