Tests[CreateUser]

This commit is contained in:
2022-11-30 10:35:05 +01:00
parent ac9ae06cc8
commit df4eb15df8
4 changed files with 194 additions and 74 deletions

View File

@@ -1,50 +1,44 @@
package test
import (
"fmt"
"testing"
"time"
)
func TestWebserver(t *testing.T) {
ws, stop := NewSimpleWebserver()
ws, stop := StartSimpleWebserver(t)
defer stop()
go func() { ws.Run() }()
time.Sleep(100 * time.Millisecond)
fmt.Printf("Port := %s\n", ws.Port)
}
func TestPing(t *testing.T) {
ws, stop := NewSimpleWebserver()
ws, stop := StartSimpleWebserver(t)
defer stop()
go func() { ws.Run() }()
time.Sleep(100 * time.Millisecond)
baseUrl := "http://127.0.0.1:" + ws.Port
_ = requestGet[Void](baseUrl, "/api/ping")
_ = requestPut[Void](baseUrl, "/api/ping", nil)
_ = requestPost[Void](baseUrl, "/api/ping", nil)
_ = requestPatch[Void](baseUrl, "/api/ping", nil)
_ = requestDelete[Void](baseUrl, "/api/ping", nil)
_ = 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)
}
func TestMongo(t *testing.T) {
ws, stop := NewSimpleWebserver()
ws, stop := StartSimpleWebserver(t)
defer stop()
go func() { ws.Run() }()
time.Sleep(100 * time.Millisecond)
baseUrl := "http://127.0.0.1:" + ws.Port
_ = requestPost[Void](baseUrl, "/api/db-test", nil)
_ = requestPost[Void](t, baseUrl, "/api/db-test", nil)
}
func TestHealth(t *testing.T) {
ws, stop := NewSimpleWebserver()
ws, stop := StartSimpleWebserver(t)
defer stop()
go func() { ws.Run() }()
time.Sleep(100 * time.Millisecond)
baseUrl := "http://127.0.0.1:" + ws.Port
_ = requestGet[Void](baseUrl, "/api/health")
_ = requestGet[Void](t, baseUrl, "/api/health")
}