Skip to content

Commit

Permalink
Fix errors with new record_unknown_job_error endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Nov 16, 2023
1 parent aa3dc4b commit 20755d0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/model/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
11 changes: 11 additions & 0 deletions internal/server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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))
}
Expand Down Expand Up @@ -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")
}

0 comments on commit 20755d0

Please sign in to comment.