Skip to content

Commit

Permalink
Fix test.
Browse files Browse the repository at this point in the history
  • Loading branch information
getvictor committed Oct 30, 2024
1 parent e31bd1b commit 4dfcce3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions server/fleet/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ func (fe FleetdError) Error() string {
// about the error can be logged by the components that use zerolog (Orbit,
// Fleet Desktop)
func (fe FleetdError) MarshalZerologObject(e *zerolog.Event) {
e.Bool("vital", fe.Vital)
e.Str("error_source", fe.ErrorSource)
e.Str("error_source_version", fe.ErrorSourceVersion)
e.Time("error_timestamp", fe.ErrorTimestamp)
Expand Down
8 changes: 6 additions & 2 deletions server/fleet/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/rs/zerolog"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -62,7 +63,8 @@ func TestFleetdErrors(t *testing.T) {
}

require.Equal(t, "test message", ferr.Error())
require.Equal(t, map[string]any{
assert.Equal(t, map[string]any{
"vital": ferr.Vital,
"error_source": ferr.ErrorSource,
"error_source_version": ferr.ErrorSourceVersion,
"error_timestamp": ferr.ErrorTimestamp,
Expand All @@ -75,5 +77,7 @@ func TestFleetdErrors(t *testing.T) {
zevent := logger.Log()
ferr.MarshalZerologObject(zevent)
zevent.Send()
require.JSONEq(t, `{"error_source":"orbit","error_source_version":"1.1.1","error_timestamp":"1969-06-19T21:44:05Z","error_message":"test message","error_additional_info":{"foo":"bar"}}`, logBuf.String())
assert.JSONEq(t,
`{"error_source":"orbit","error_source_version":"1.1.1","error_timestamp":"1969-06-19T21:44:05Z","error_message":"test message","error_additional_info":{"foo":"bar"},"vital":false}`,
logBuf.String())
}

0 comments on commit 4dfcce3

Please sign in to comment.