github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/pkg/model/custom_build_test.go (about)

     1  package model
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  
     8  	"github.com/tilt-dev/tilt/internal/container"
     9  	"github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1"
    10  )
    11  
    12  func TestValidate(t *testing.T) {
    13  	cb := CustomBuild{
    14  		CmdImageSpec: v1alpha1.CmdImageSpec{Args: ToHostCmd("exit 0").Argv},
    15  		Deps:         []string{"foo", "bar"},
    16  	}
    17  	it := MustNewImageTarget(container.MustParseSelector("gcr.io/foo/bar")).
    18  		WithBuildDetails(cb)
    19  
    20  	assert.Nil(t, it.Validate())
    21  }
    22  
    23  func TestDoesNotValidate(t *testing.T) {
    24  	cb := CustomBuild{
    25  		CmdImageSpec: v1alpha1.CmdImageSpec{},
    26  		Deps:         []string{"foo", "bar"},
    27  	}
    28  	it := MustNewImageTarget(container.MustParseSelector("gcr.io/foo/bar")).
    29  		WithBuildDetails(cb)
    30  
    31  	assert.Error(t, it.Validate())
    32  }