Manager: construct api.Worker from api.WorkerSummary + extra fields

This commit is contained in:
Sybren A. Stüvel 2022-05-31 15:30:46 +02:00
parent 90707dceed
commit 3063e1fe6d
2 changed files with 19 additions and 13 deletions

View File

@ -68,13 +68,15 @@ func workerSummary(w persistence.Worker) api.WorkerSummary {
func workerDBtoAPI(dbWorker *persistence.Worker) api.Worker {
apiWorker := api.Worker{
WorkerSummary: api.WorkerSummary{
Id: dbWorker.UUID,
IpAddress: dbWorker.Address,
Nickname: dbWorker.Name,
Platform: dbWorker.Platform,
Status: dbWorker.Status,
SupportedTaskTypes: dbWorker.TaskTypes(),
Version: dbWorker.Software,
},
IpAddress: dbWorker.Address,
Platform: dbWorker.Platform,
SupportedTaskTypes: dbWorker.TaskTypes(),
}
if dbWorker.StatusRequested != "" {

View File

@ -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{
WorkerSummary: api.WorkerSummary{
Id: workerUUID,
Nickname: "дрон",
IpAddress: "fe80::5054:ff:fede:2ad7",
Platform: "linux",
Version: "3.0",
Status: api.WorkerStatusAwake,
},
IpAddress: "fe80::5054:ff:fede:2ad7",
Platform: "linux",
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{
WorkerSummary: api.WorkerSummary{
Id: workerUUID,
Nickname: "дрон",
IpAddress: "fe80::5054:ff:fede:2ad7",
Platform: "linux",
Version: "3.0",
Status: api.WorkerStatusAwake,
StatusRequested: &requestedStatus,
},
IpAddress: "fe80::5054:ff:fede:2ad7",
Platform: "linux",
SupportedTaskTypes: []string{"blender", "ffmpeg", "file-management", "misc"},
})
}