refactor(web): web.New takes the jobs service (#7)

This commit is contained in:
2026-10-12 18:39:57 +02:00
parent 9e09de0a16
commit c9c4e0cadb
3 changed files with 30 additions and 5 deletions
+16 -2
View File
@@ -34,7 +34,14 @@ type fakeStore struct {
}
func (f *fakeStore) ListServices(context.Context) ([]model.Service, error) { return f.services, nil }
func (f *fakeStore) ListAgents(context.Context) ([]model.Agent, error) { return f.agents, nil }
func (f *fakeStore) GetService(context.Context, int64) (model.Service, error) {
return model.Service{}, model.ErrNotFound
}
func (f *fakeStore) GetJob(context.Context, int64) (model.Job, error) {
return model.Job{}, model.ErrNotFound
}
func (f *fakeStore) ListJobs(context.Context, model.JobFilter) ([]model.Job, error) { return nil, nil }
func (f *fakeStore) ListAgents(context.Context) ([]model.Agent, error) { return f.agents, nil }
func (f *fakeStore) CreateAgent(_ context.Context, name, hash string) (model.Agent, error) {
f.mu.Lock()
@@ -65,6 +72,13 @@ func (f *fakeStore) revoked() int64 {
return f.revokedID
}
type fakeJobs struct{}
func (fakeJobs) Updatable(model.Service) error { return nil }
func (fakeJobs) Trigger(context.Context, int64, string) (model.Job, error) {
return model.Job{}, model.ErrNotFound
}
type fakeHub struct {
mu sync.Mutex
online map[int64]bool
@@ -110,7 +124,7 @@ func newTestServer(t *testing.T) (*httptest.Server, *fakeStore, *fakeHub, *event
}
hub := &fakeHub{online: map[int64]bool{2: true}}
broker := events.NewBroker()
s, err := New(store, hub, broker, Config{
s, err := New(store, hub, fakeJobs{}, broker, Config{
AgentURL: "wss://10.0.0.5:8090/agent", MasterKey: "sha256:abc", AgentImage: "gitea.shcizo.se/shcizo/package-updater:latest",
}, slog.New(slog.NewTextHandler(io.Discard, nil)))
require.NoError(t, err)