TestNew | Basic middleware creation with custom resolver | Tenant stored in context and accessible via Get() |
TestWithOptions_Required | Required tenant resolution fails | Returns 400 Bad Request when tenant not found |
TestWithOptions_NotRequired | Optional tenant resolution | Continues without tenant, Get() returns nil |
TestSubdomainResolver | Extract tenant from subdomain | Resolves “acme” from “acme.example.com” |
TestHeaderResolver | Extract tenant from HTTP header | Resolves tenant from “X-Tenant-Id” header |
TestPathResolver | Extract tenant from URL path prefix | Resolves “acme” from “/acme/api/users” and rewrites path to “/api/users” |
TestQueryResolver | Extract tenant from query parameter | Resolves tenant from “?tenant=my-tenant” |
TestLookupResolver | Database lookup enrichment | Enhances basic tenant with full data from lookup function |
TestChainResolver | Multiple resolver fallback | Tries header, then query, then subdomain in order |
TestFromContext | Alias function for Get | FromContext() returns same tenant as Get() |
TestMustGet | Get tenant or panic | Returns tenant when present |
TestMustGet_Panic | Panic on missing tenant | Panics with “tenant not found” message when tenant absent |
TestErrors | Error constants | Validates error messages for ErrTenantNotFound and ErrTenantInvalid |
TestWithOptions_ErrorHandler | Custom error handling | Uses custom error handler to return 401 Unauthorized |