github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/engine/daemon/logger/journald/journald_test.go (about) 1 //go:build linux 2 // +build linux 3 4 package journald // import "github.com/docker/docker/daemon/logger/journald" 5 6 import ( 7 "testing" 8 ) 9 10 func TestSanitizeKeyMod(t *testing.T) { 11 entries := map[string]string{ 12 "io.kubernetes.pod.name": "IO_KUBERNETES_POD_NAME", 13 "io?.kubernetes.pod.name": "IO__KUBERNETES_POD_NAME", 14 "?io.kubernetes.pod.name": "IO_KUBERNETES_POD_NAME", 15 "io123.kubernetes.pod.name": "IO123_KUBERNETES_POD_NAME", 16 "_io123.kubernetes.pod.name": "IO123_KUBERNETES_POD_NAME", 17 "__io123_kubernetes.pod.name": "IO123_KUBERNETES_POD_NAME", 18 } 19 for k, v := range entries { 20 if sanitizeKeyMod(k) != v { 21 t.Fatalf("Failed to sanitize %s, got %s, expected %s", k, sanitizeKeyMod(k), v) 22 } 23 } 24 }