From 2e92e05c465ac0f0c8bb6c9a792456da2ec36271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 16 Nov 2023 14:50:11 +0100 Subject: [PATCH] Fix errors with new record_unknown_job_error endpoint (#197) --- internal/model/update.go | 5 +++++ internal/server/api.go | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/internal/model/update.go b/internal/model/update.go index 763c518..251631f 100644 --- a/internal/model/update.go +++ b/internal/model/update.go @@ -60,6 +60,11 @@ type RecordUpdateJobError struct { ErrorDetails map[string]any `json:"error-details" yaml:"error-details"` } +type RecordUpdateJobUnknownError struct { + ErrorType string `json:"error-type" yaml:"error-type"` + ErrorDetails map[string]any `json:"error-details" yaml:"error-details"` +} + type IncrementMetric struct { Metric string `json:"metric" yaml:"metric"` Tags map[string]any `json:"tags" yaml:"tags"` diff --git a/internal/server/api.go b/internal/server/api.go index 5567f3a..00d24d5 100644 --- a/internal/server/api.go +++ b/internal/server/api.go @@ -233,6 +233,8 @@ func decodeWrapper(kind string, data []byte) (actual *model.UpdateWrapper, err e actual.Data, err = decode[model.RecordEcosystemVersions](data) case "record_update_job_error": actual.Data, err = decode[model.RecordUpdateJobError](data) + case "record_update_job_unknown_error": + actual.Data, err = decode[model.RecordUpdateJobUnknownError](data) case "increment_metric": actual.Data, err = decode[model.IncrementMetric](data) default: @@ -285,6 +287,8 @@ func compare(expect, actual *model.UpdateWrapper) error { return compareMarkAsProcessed(v, actual.Data.(model.MarkAsProcessed)) case model.RecordUpdateJobError: return compareRecordUpdateJobError(v, actual.Data.(model.RecordUpdateJobError)) + case model.RecordUpdateJobUnknownError: + return compareRecordUpdateJobUnknownError(v, actual.Data.(model.RecordUpdateJobUnknownError)) default: return fmt.Errorf("unexpected type: %s", reflect.TypeOf(v)) } @@ -342,3 +346,10 @@ func compareRecordUpdateJobError(expect, actual model.RecordUpdateJobError) erro } return unexpectedBody("record_update_job_error") } + +func compareRecordUpdateJobUnknownError(expect, actual model.RecordUpdateJobUnknownError) error { + if reflect.DeepEqual(expect, actual) { + return nil + } + return unexpectedBody("record_update_job_unknown_error") +}