1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration/internal/termtest/stripansi_test.go
Paweł Gronowski 2ec3e14c0f test: Add tests for logging
1. Add integration tests for the ContainerLogs API call
Each test handle a distinct case of ContainerLogs output.
- Muxed stream, when container is started without tty
- Single stream, when container is started with tty

2. Add unit test for LogReader suite that tests concurrent logging
It checks that there are no race conditions when logging concurrently
from multiple goroutines.

Co-authored-by: Cory Snider <csnider@mirantis.com>
Signed-off-by: Cory Snider <csnider@mirantis.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2022-06-10 09:26:17 +02:00

26 lines
745 B
Go

package termtest // import "github.com/docker/docker/integration/internal/termtest"
import (
"testing"
"gotest.tools/v3/assert"
)
func TestStripANSICommands(t *testing.T) {
for _, tt := range []struct{ input, want string }{
{
input: "\x1b[2J\x1b[?25l\x1b[m\x1b[Hthis is fine\b\x1b]0;C:\\bin\\sh.exe\x00\a\x1b[?25h\x1b[Ht\x1b[1;13H\x1b[?25laccidents happen \b\x1b[?25h\x1b[Ht\x1b[1;29H",
want: "this is fineaccidents happen",
},
{
input: "\x1b[2J\x1b[m\x1b[Hthis is fine\x1b]0;C:\\bin\\sh.exe\a\x1b[?25haccidents happen",
want: "this is fineaccidents happen",
},
} {
t.Run("", func(t *testing.T) {
got, err := StripANSICommands(tt.input)
assert.NilError(t, err)
assert.DeepEqual(t, tt.want, got)
})
}
}