From 3063e1fe6dd024a81c9709e93011993f1d0e2b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 31 May 2022 15:30:46 +0200 Subject: [PATCH] Manager: construct `api.Worker` from `api.WorkerSummary` + extra fields --- internal/manager/api_impl/worker_mgt.go | 10 +++++---- internal/manager/api_impl/worker_mgt_test.go | 22 ++++++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/internal/manager/api_impl/worker_mgt.go b/internal/manager/api_impl/worker_mgt.go index 2d8a9487..0b9fabeb 100644 --- a/internal/manager/api_impl/worker_mgt.go +++ b/internal/manager/api_impl/worker_mgt.go @@ -68,13 +68,15 @@ func workerSummary(w persistence.Worker) api.WorkerSummary { func workerDBtoAPI(dbWorker *persistence.Worker) api.Worker { apiWorker := api.Worker{ - Id: dbWorker.UUID, + WorkerSummary: api.WorkerSummary{ + Id: dbWorker.UUID, + Nickname: dbWorker.Name, + Status: dbWorker.Status, + Version: dbWorker.Software, + }, IpAddress: dbWorker.Address, - Nickname: dbWorker.Name, Platform: dbWorker.Platform, - Status: dbWorker.Status, SupportedTaskTypes: dbWorker.TaskTypes(), - Version: dbWorker.Software, } if dbWorker.StatusRequested != "" { diff --git a/internal/manager/api_impl/worker_mgt_test.go b/internal/manager/api_impl/worker_mgt_test.go index 2a2d52bf..213196bd 100644 --- a/internal/manager/api_impl/worker_mgt_test.go +++ b/internal/manager/api_impl/worker_mgt_test.go @@ -87,12 +87,14 @@ func TestFetchWorker(t *testing.T) { err = mf.flamenco.FetchWorker(echo, workerUUID) assert.NoError(t, err) assertResponseJSON(t, echo, http.StatusOK, api.Worker{ - Id: workerUUID, - Nickname: "дрон", + WorkerSummary: api.WorkerSummary{ + Id: workerUUID, + Nickname: "дрон", + Version: "3.0", + Status: api.WorkerStatusAwake, + }, IpAddress: "fe80::5054:ff:fede:2ad7", Platform: "linux", - Version: "3.0", - Status: api.WorkerStatusAwake, SupportedTaskTypes: []string{"blender", "ffmpeg", "file-management", "misc"}, }) @@ -105,13 +107,15 @@ func TestFetchWorker(t *testing.T) { err = mf.flamenco.FetchWorker(echo, worker.UUID) assert.NoError(t, err) assertResponseJSON(t, echo, http.StatusOK, api.Worker{ - Id: workerUUID, - Nickname: "дрон", + WorkerSummary: api.WorkerSummary{ + Id: workerUUID, + Nickname: "дрон", + Version: "3.0", + Status: api.WorkerStatusAwake, + StatusRequested: &requestedStatus, + }, IpAddress: "fe80::5054:ff:fede:2ad7", Platform: "linux", - Version: "3.0", - Status: api.WorkerStatusAwake, - StatusRequested: &requestedStatus, SupportedTaskTypes: []string{"blender", "ffmpeg", "file-management", "misc"}, }) }