github.com/mitchellh/packer@v1.3.2/builder/docker/exec_test.go (about)

     1  package docker
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestCleanLine(t *testing.T) {
     8  	cases := []struct {
     9  		input  string
    10  		output string
    11  	}{
    12  		{
    13  			"\x1b[0A\x1b[2K\r8dbd9e392a96: Pulling image (precise) from ubuntu\r\x1b[0B\x1b[1A\x1b[2K\r8dbd9e392a96: Pulling image (precise) from ubuntu, endpoint: https://cdn-registry-1.docker.io/v1/\r\x1b[1B",
    14  			"8dbd9e392a96: Pulling image (precise) from ubuntu, endpoint: https://cdn-registry-1.docker.io/v1/",
    15  		},
    16  	}
    17  
    18  	for _, tc := range cases {
    19  		actual := cleanOutputLine(tc.input)
    20  		if actual != tc.output {
    21  			t.Fatalf("bad: %#v %#v", tc.input, actual)
    22  		}
    23  	}
    24  }