Skip to content

Commit 3cdb1b0

Browse files
committed
fix: update api-gateway test stubs to match slugCache interface
The slugCache interface now returns (TenantID, string, error) from Get and accepts a status string in Set. Update authFlowSlugCache and stubSlugCache test stubs to match, and add missing Invalidate methods.
1 parent 5c06cec commit 3cdb1b0

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

services/api-gateway/auth_flows_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,21 @@ type authFlowSlugCache struct {
5656
entries map[string]tenant.TenantID
5757
}
5858

59-
func (c *authFlowSlugCache) Get(_ context.Context, slug string) (tenant.TenantID, error) {
59+
func (c *authFlowSlugCache) Get(_ context.Context, slug string) (tenant.TenantID, string, error) {
6060
id, ok := c.entries[slug]
6161
if !ok {
62-
return "", nil
62+
return "", "", nil
6363
}
64-
return id, nil
64+
return id, "", nil
6565
}
6666

67-
func (c *authFlowSlugCache) Set(_ context.Context, slug string, tenantID tenant.TenantID) error {
67+
func (c *authFlowSlugCache) Set(_ context.Context, slug string, tenantID tenant.TenantID, _ string) error {
6868
c.entries[slug] = tenantID
6969
return nil
7070
}
7171

72+
func (c *authFlowSlugCache) Invalidate(_ context.Context, _ string) {}
73+
7274
// authFlowTenantRepo satisfies the tenantRepository interface for TenantResolverMiddleware.
7375
type authFlowTenantRepo struct {
7476
tenants map[string]*tdomain.Tenant

services/api-gateway/server_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -848,19 +848,21 @@ func newStubSlugCache() *stubSlugCache {
848848
return &stubSlugCache{entries: make(map[string]tenant.TenantID)}
849849
}
850850

851-
func (c *stubSlugCache) Get(_ context.Context, slug string) (tenant.TenantID, error) {
851+
func (c *stubSlugCache) Get(_ context.Context, slug string) (tenant.TenantID, string, error) {
852852
id, ok := c.entries[slug]
853853
if !ok {
854-
return "", nil // cache miss
854+
return "", "", nil // cache miss
855855
}
856-
return id, nil
856+
return id, "", nil
857857
}
858858

859-
func (c *stubSlugCache) Set(_ context.Context, slug string, tenantID tenant.TenantID) error {
859+
func (c *stubSlugCache) Set(_ context.Context, slug string, tenantID tenant.TenantID, _ string) error {
860860
c.entries[slug] = tenantID
861861
return nil
862862
}
863863

864+
func (c *stubSlugCache) Invalidate(_ context.Context, _ string) {}
865+
864866
// stubTenantRepo is a minimal tenant repository for testing.
865867
// It satisfies the unexported tenantRepository interface used by NewTenantResolverMiddleware.
866868
type stubTenantRepo struct {

0 commit comments

Comments
 (0)