ultisuite-backend/internal/integrationtest/mail/settings_test.go
R3D347HR4Y fa5394e10d feat(tests): add integration testing framework and configuration
- 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.
2026-06-07 19:44:29 +02:00

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"])
}
}