Unit test exercising logger's custom With() function
@@ -114,6 +114,26 @@ func TestComponent(t *testing.T) {
tearDown()
}
+func TestWith(t *testing.T) {
+ setUp()
+ log := MakeLogger(MockLogger{})
+
+ log.With("arg1", "val1").Log("foo1", "bar1")
+ log.With("arg2", "val2").Log("foo2", "bar2")
+
+ assert(t, len(logParams) == 2, "Expected 2 log lines")
+
+ logEntry := logParams[0].([]interface{})
+ assert(t, logEntry[8].(string) == "arg1", "Custom With() field was not logged")
+ assert(t, logEntry[9].(string) == "val1", "Custom With() field was not logged")
+
+ logEntry = logParams[1].([]interface{})
+ assert(t, logEntry[8].(string) == "arg2", "Custom With() was not logged")
+ assert(t, logEntry[9].(string) == "val2", "Custom With() was not logged")
+
+ tearDown()
+}
+
func TestInfoCutoff(t *testing.T) {
setUp()
log := MakeLogger(MockLogger{})
