Add agent

This commit is contained in:
2023-07-03 18:43:27 -04:00
parent b1b010deee
commit f82d3f18c6
6 changed files with 137 additions and 15 deletions

View File

@@ -23,6 +23,16 @@ func (repo FakeRepo) IsRegistered(name string) bool {
return false
}
func (repo FakeRepo) GetApp(name string) (svc.Application, error) {
for _, app := range repo.apps {
if name == app.Name {
return *app, nil
}
}
return svc.Application{}, svc.ErrApplicationNotFound
}
func (repo FakeRepo) PendingApprovalCount() int {
count := 0
for _, app := range repo.apps {
@@ -34,26 +44,23 @@ func (repo FakeRepo) PendingApprovalCount() int {
}
func (repo *FakeRepo) StartAppRegistration(name string) uuid.UUID {
repo.apps = append(repo.apps, &svc.Application{
newApp := &svc.Application{
ID: uuid.New(),
Name: name,
State: "pending_approval",
})
return uuid.New()
}
repo.apps = append(repo.apps, newApp)
return newApp.ID
}
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"
return *application, nil
}
}
if app == nil {
return svc.Application{}, svc.ErrApplicationNotFound
}
return *app, nil
return svc.Application{}, svc.ErrApplicationNotFound
}