mirror of
https://github.com/docker/cli.git
synced 2026-01-13 18:22:35 +03:00
Fix a error of the function 'CopyMessage' in 'daemon/logger/logger.go'
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn> add a test for 'CopyMessage' Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn> update Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn> Upstream-commit: 3b82eac65fc365a89f64ccaba98f8f3b5c9c5787 Component: engine
This commit is contained in:
@@ -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
|
||||
|
||||
26
components/engine/daemon/logger/logger_test.go
Normal file
26
components/engine/daemon/logger/logger_test.go
Normal 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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user