github.com/grahambrereton-form3/tilt@v0.10.18/pkg/model/squash_test.go (about)

     1  package model
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func TestSquash(t *testing.T) {
    10  	cmds := ToShellCmds([]string{"echo a", "echo b", "echo c"})
    11  	cmds = TrySquash(cmds)
    12  	assert.Equal(t, []Cmd{Cmd{
    13  		Argv: []string{
    14  			"sh",
    15  			"-exc",
    16  			"echo a;\necho b;\necho c",
    17  		},
    18  	}}, cmds)
    19  }
    20  
    21  func TestSquashFail(t *testing.T) {
    22  	cmds := []Cmd{ToShellCmd("echo a"), Cmd{Argv: []string{"echo"}}, ToShellCmd("echo c")}
    23  	cmds2 := TrySquash(cmds)
    24  	assert.Equal(t, cmds, cmds2)
    25  }
    26  
    27  func TestSquashPartial(t *testing.T) {
    28  	cmds := []Cmd{ToShellCmd("echo a"), ToShellCmd("echo c"), Cmd{Argv: []string{"echo"}}}
    29  	cmds2 := TrySquash(cmds)
    30  	assert.Equal(t, []Cmd{
    31  		Cmd{
    32  			Argv: []string{
    33  				"sh",
    34  				"-exc",
    35  				"echo a;\necho c",
    36  			},
    37  		},
    38  		cmds[2],
    39  	}, cmds2)
    40  }