- 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.
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
//go:build integration
|
|
|
|
package mail_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/ultisuite/ulti-backend/internal/integrationtest"
|
|
)
|
|
|
|
func TestMailSettingsCRUD(t *testing.T) {
|
|
h := integrationtest.RequireHarness(t)
|
|
client, claims := integrationtest.RequireUserClient(t, h)
|
|
|
|
resp, err := client.Get("/api/v1/mail/settings")
|
|
integrationtest.FailIf(err, t, "GET settings")
|
|
integrationtest.FailUnlessStatus(t, resp, 200)
|
|
integrationtest.AssertUserProvisioned(t, h, claims.Sub)
|
|
|
|
var defaults map[string]any
|
|
integrationtest.DecodeJSON(t, resp, &defaults)
|
|
if defaults["density"] != "default" {
|
|
t.Fatalf("density = %v, want default", defaults["density"])
|
|
}
|
|
|
|
resp, err = client.Patch("/api/v1/mail/settings", map[string]string{"density": "compact"})
|
|
integrationtest.FailIf(err, t, "PATCH settings")
|
|
integrationtest.FailUnlessStatus(t, resp, 200)
|
|
|
|
var updated map[string]any
|
|
integrationtest.DecodeJSON(t, resp, &updated)
|
|
if updated["density"] != "compact" {
|
|
t.Fatalf("density = %v, want compact", updated["density"])
|
|
}
|
|
|
|
resp, err = client.Get("/api/v1/mail/settings")
|
|
integrationtest.FailIf(err, t, "GET settings after patch")
|
|
integrationtest.FailUnlessStatus(t, resp, 200)
|
|
integrationtest.DecodeJSON(t, resp, &updated)
|
|
if updated["density"] != "compact" {
|
|
t.Fatalf("persisted density = %v, want compact", updated["density"])
|
|
}
|
|
}
|