frankenphp/caddy/caddy_test.go

37 lines
624 B
Go
Raw Normal View History

2021-10-31 23:18:30 +00:00
package caddy_test
import (
"fmt"
2021-10-31 23:18:30 +00:00
"net/http"
"sync"
2021-10-31 23:18:30 +00:00
"testing"
"github.com/caddyserver/caddy/v2/caddytest"
)
func TestPHP(t *testing.T) {
var wg sync.WaitGroup
caddytest.Default.AdminPort = 2019
2021-10-31 23:18:30 +00:00
tester := caddytest.NewTester(t)
tester.InitServer(`
{
admin localhost:2999
http_port 9080
https_port 9443
}
localhost:9080 {
respond "Hello"
2021-10-31 23:18:30 +00:00
}
`, "caddyfile")
2021-10-31 23:18:30 +00:00
wg.Add(100)
for i := 0; i < 100; i++ {
go func(i int) {
tester.AssertGetResponse(fmt.Sprintf("http://localhost:9080?i=%d", i), http.StatusOK, fmt.Sprintf("I am by birth a Genevese (%d)", i))
wg.Done()
}(i)
}
wg.Wait()
2021-10-31 23:18:30 +00:00
}