Example #1
0
func TestFields_OrderedKeys(t *testing.T) {
	fields := log.Fields{
		"second": 1,
		"first":  3,
		"ant":    4,
		"third":  2,
	}
	actual := fields.OrderedKeys()
	expected := []string{"ant", "first", "second", "third"}
	if !reflect.DeepEqual(actual, expected) {
		t.Errorf(`Fields.OrderedKeys() => %#v; want %#v`, actual, expected)
	}
}
Example #2
0
func TestFields_Get(t *testing.T) {
	fields := log.Fields{
		"first":  1,
		"second": "two",
		"third":  '3',
	}
	for _, v := range []struct {
		key      string
		expected interface{}
	}{
		{"first", 1},
		{"second", "two"},
		{"third", '3'},
		{"fourth", nil},
	} {
		var actual interface{} = fields.Get(v.key)
		var expected interface{} = v.expected
		if !reflect.DeepEqual(actual, expected) {
			t.Errorf(`Fields.Get(%#v) => %#v; want %#v`, v.key, actual, expected)
		}
	}
}