Files
amcs/internal/store/skills_test.go
T
SG Command 912b87404f
CI / build-and-test (push) Failing after 20s
CI / build-and-test (pull_request) Failing after 14s
fix: scope project skills by tenant
2026-08-18 00:16:35 +02:00

33 lines
765 B
Go

package store
import (
"context"
"testing"
"git.warky.dev/wdevs/amcs/internal/tenancy"
)
func TestProjectSkillTenantWhere(t *testing.T) {
args := []any{int64(1), int64(2), true}
where := projectSkillTenantWhere(tenancy.WithTenantKey(context.Background(), "tenant-a"), &args, "p", "s")
if where != " and p.tenant_id = $4 and s.tenant_id = $4" {
t.Fatalf("where = %q", where)
}
if len(args) != 4 || args[3] != "tenant-a" {
t.Fatalf("args = %#v", args)
}
}
func TestProjectSkillTenantWhereWithoutTenant(t *testing.T) {
args := []any{int64(1), int64(2)}
where := projectSkillTenantWhere(context.Background(), &args, "p", "s")
if where != "" {
t.Fatalf("where = %q, want empty", where)
}
if len(args) != 2 {
t.Fatalf("args = %#v", args)
}
}