- Introduced a new `.env.test.example` file for integration test configuration. - Added a `Makefile` to streamline test commands for unit and integration tests. - Implemented an integration testing harness with support for PostgreSQL, MinIO, and Redis using testcontainers. - Created a suite of integration tests covering health checks and user management functionalities. - Enhanced CI workflow to include integration tests with necessary environment variables.
36 lines
893 B
Go
36 lines
893 B
Go
//go:build integration
|
|
|
|
package search_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/ultisuite/ulti-backend/internal/integrationtest"
|
|
)
|
|
|
|
func TestSearchPostgresEmptyQuery(t *testing.T) {
|
|
h := integrationtest.RequireHarness(t)
|
|
client, _ := integrationtest.RequireUserClient(t, h)
|
|
|
|
resp, err := client.Get("/api/v1/search?q=hello")
|
|
integrationtest.FailIf(err, t, "search")
|
|
integrationtest.FailUnlessStatus(t, resp, 200)
|
|
|
|
var body map[string]any
|
|
integrationtest.DecodeJSON(t, resp, &body)
|
|
if body["results"] == nil {
|
|
t.Fatalf("missing results field: %#v", body)
|
|
}
|
|
}
|
|
|
|
func TestSearchRequiresAuth(t *testing.T) {
|
|
h := integrationtest.RequireHarness(t)
|
|
client := integrationtest.NewClient(h.Server.URL, "")
|
|
|
|
resp, err := client.Get("/api/v1/search?q=test")
|
|
integrationtest.FailIf(err, t, "search without auth")
|
|
if resp.Status != 401 {
|
|
t.Fatalf("status = %d, want 401", resp.Status)
|
|
}
|
|
}
|