package main import ( "testing" ) import "github.com/gavv/httpexpect/v2" func startServer(t *testing.T) { config := ServerConfig{ Datasource: ":memory:", Port: "8181", Started: make(chan bool), } go start(t.Context(), &config) <-config.Started } func TestGetUsers(t *testing.T) { startServer(t) e := httpexpect.Default(t, "http://localhost:8181/api") result := e.GET("/users").Expect().Status(200).JSON() result.Array().Length().IsEqual(2) result.Path("$[0].name").InList("Seeseemelk", "Huffle") result.Path("$[1].name").InList("Seeseemelk", "Huffle") }