...
1 package keyvals
2
3 import (
4 "errors"
5 "testing"
6 )
7
8 func TestToMap(t *testing.T) {
9 err := errors.New("error")
10 actual := ToMap([]interface{}{"key", "value", "error", err})
11
12 expected := map[string]interface{}{
13 "key": "value",
14 "error": err,
15 }
16
17 if len(expected) != len(actual) {
18 t.Fatalf("expected log fields to be equal\ngot: %v\nwant: %v", actual, expected)
19 }
20
21 for key, value := range expected {
22 if actual[key] != value {
23 t.Errorf("expected log fields to be equal\ngot: %v\nwant: %v", actual, expected)
24 }
25 }
26 }
27
View as plain text