package persistence import ( "github.com/google/uuid" svc "go.fixergrid.net/servicedemon/pkg/registrar/internal/services" ) type FakeRepo struct { apps []*svc.Application } func NewFakeRepo() *FakeRepo { return &FakeRepo{ apps: make([]*svc.Application, 0), } } func (repo FakeRepo) IsRegistered(name string) bool { for _, app := range repo.apps { if name == app.Name && app.State == "registered" { return true } } return false } func (repo FakeRepo) PendingApprovalCount() int { count := 0 for _, app := range repo.apps { if app.State == "pending_approval" { count += 1 } } return count } func (repo *FakeRepo) StartAppRegistration(name string) uuid.UUID { repo.apps = append(repo.apps, &svc.Application{ Name: name, State: "pending_approval", }) return uuid.New() } func (repo *FakeRepo) ApproveApp(id uuid.UUID) (svc.Application, error) { var app *svc.Application for _, application := range repo.apps { if application.ID == id { application.State = "registered" } } if app == nil { return svc.Application{}, svc.ErrApplicationNotFound } return *app, nil }