Skip to content

Commit

Permalink
rename expected to want
Browse files Browse the repository at this point in the history
  • Loading branch information
dmathieu committed Apr 10, 2024
1 parent 3712c2f commit 4cdf838
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions bridges/otellogrus/hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ func TestHookLevels(t *testing.T) {
name string
options []Option

expectedLevels []logrus.Level
wantLevels []logrus.Level
}{
{
name: "with the default levels",
expectedLevels: logrus.AllLevels,
name: "with the default levels",
wantLevels: logrus.AllLevels,
},
{
name: "with provided levels",
options: []Option{
WithLevels([]logrus.Level{logrus.PanicLevel}),
},
expectedLevels: []logrus.Level{logrus.PanicLevel},
wantLevels: []logrus.Level{logrus.PanicLevel},
},
} {
t.Run(tt.name, func(t *testing.T) {
levels := NewHook(tt.options...).Levels()
assert.Equal(t, tt.expectedLevels, levels)
assert.Equal(t, tt.wantLevels, levels)
})
}
}
Expand All @@ -50,14 +50,14 @@ func TestHookFire(t *testing.T) {
name string
entry *logrus.Entry

expectedRecords map[string][]log.Record
expectedErr error
wantRecords map[string][]log.Record
wantErr error
}{
{
name: "emits an empty log entry",
entry: &logrus.Entry{},

expectedRecords: map[string][]log.Record{
wantRecords: map[string][]log.Record{
bridgeName: []log.Record{
buildRecord(log.StringValue(""), time.Time{}, 0, nil),
},
Expand All @@ -68,7 +68,7 @@ func TestHookFire(t *testing.T) {
entry: &logrus.Entry{
Time: now,
},
expectedRecords: map[string][]log.Record{
wantRecords: map[string][]log.Record{
bridgeName: []log.Record{
buildRecord(log.StringValue(""), now, 0, nil),
},
Expand All @@ -79,7 +79,7 @@ func TestHookFire(t *testing.T) {
entry: &logrus.Entry{
Level: logrus.FatalLevel,
},
expectedRecords: map[string][]log.Record{
wantRecords: map[string][]log.Record{
bridgeName: []log.Record{
buildRecord(log.StringValue(""), time.Time{}, log.SeverityTrace1, nil),
},
Expand All @@ -93,7 +93,7 @@ func TestHookFire(t *testing.T) {
"answer": 42,
},
},
expectedRecords: map[string][]log.Record{
wantRecords: map[string][]log.Record{
bridgeName: []log.Record{
buildRecord(log.StringValue(""), time.Time{}, 0, []log.KeyValue{
log.String("hello", "world"),
Expand All @@ -107,9 +107,9 @@ func TestHookFire(t *testing.T) {
rec := logtest.NewRecorder()

err := NewHook(WithLoggerProvider(rec)).Fire(tt.entry)
assert.Equal(t, tt.expectedErr, err)
assert.Equal(t, tt.wantErr, err)

for k, v := range tt.expectedRecords {
for k, v := range tt.wantRecords {
found := false

for _, s := range rec.Result() {
Expand All @@ -119,7 +119,7 @@ func TestHookFire(t *testing.T) {
}
}

assert.Truef(t, found, "expected to find records with a scope named %q", k)
assert.Truef(t, found, "want to find records with a scope named %q", k)
}
})
}
Expand All @@ -129,60 +129,60 @@ func TestConvertFields(t *testing.T) {
for _, tt := range []struct {
name string

fields logrus.Fields
expectedKeyValue []log.KeyValue
fields logrus.Fields
wantKeyValue []log.KeyValue
}{
{
name: "with a boolean",

fields: logrus.Fields{"hello": true},
expectedKeyValue: []log.KeyValue{
wantKeyValue: []log.KeyValue{
log.Bool("hello", true),
},
},
{
name: "with a bytes array",

fields: logrus.Fields{"hello": []byte("world")},
expectedKeyValue: []log.KeyValue{
wantKeyValue: []log.KeyValue{
log.Bytes("hello", []byte("world")),
},
},
{
name: "with a float64",

fields: logrus.Fields{"hello": 6.5},
expectedKeyValue: []log.KeyValue{
wantKeyValue: []log.KeyValue{
log.Float64("hello", 6.5),
},
},
{
name: "with an int",

fields: logrus.Fields{"hello": 42},
expectedKeyValue: []log.KeyValue{
wantKeyValue: []log.KeyValue{
log.Int("hello", 42),
},
},
{
name: "with an int64",

fields: logrus.Fields{"hello": int64(42)},
expectedKeyValue: []log.KeyValue{
wantKeyValue: []log.KeyValue{
log.Int64("hello", 42),
},
},
{
name: "with a string",

fields: logrus.Fields{"hello": "world"},
expectedKeyValue: []log.KeyValue{
wantKeyValue: []log.KeyValue{
log.String("hello", "world"),
},
},
} {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, convertFields(tt.fields), tt.expectedKeyValue)
assert.Equal(t, convertFields(tt.fields), tt.wantKeyValue)
})
}
}
Expand Down

0 comments on commit 4cdf838

Please sign in to comment.