1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #28797 from miaoyq/fix-a-err-of-logger

Fix a error of the function 'CopyMessage' in 'daemon/logger/logger.go'
This commit is contained in:
Alexander Morozov 2016-11-30 13:27:40 -08:00 committed by GitHub
commit 6151ad19ad
2 changed files with 27 additions and 1 deletions

View file

@ -49,7 +49,7 @@ func CopyMessage(msg *Message) *Message {
m.Timestamp = msg.Timestamp
m.Partial = msg.Partial
m.Attrs = make(LogAttributes)
for k, v := range m.Attrs {
for k, v := range msg.Attrs {
m.Attrs[k] = v
}
return m

View file

@ -0,0 +1,26 @@
package logger
import (
"reflect"
"testing"
"time"
)
func TestCopyMessage(t *testing.T) {
msg := &Message{
Line: []byte("test line."),
Source: "stdout",
Timestamp: time.Now(),
Attrs: LogAttributes{
"key1": "val1",
"key2": "val2",
"key3": "val3",
},
Partial: true,
}
m := CopyMessage(msg)
if !reflect.DeepEqual(m, msg) {
t.Fatalf("CopyMessage failed to copy message")
}
}