github.com/tilt-dev/tilt@v0.36.0/internal/tiltfile/local_resource_test.go (about)

     1  package tiltfile
     2  
     3  import "testing"
     4  
     5  func TestTestFnDeprecated(t *testing.T) {
     6  	f := newFixture(t)
     7  
     8  	f.file("Tiltfile", `
     9  test("test", "echo hi")
    10  `)
    11  	f.loadAssertWarnings(testDeprecationMsg)
    12  }
    13  
    14  func TestLocalResourceDirWithoutCmd(t *testing.T) {
    15  	f := newFixture(t)
    16  
    17  	f.file("Tiltfile", `
    18  local_resource("test", serve_cmd="python server.py", dir="./foo")
    19  `)
    20  	f.loadErrString("'dir' only affects 'cmd', not 'serve_cmd'. Did you mean to use 'serve_dir' instead?")
    21  }
    22  
    23  func TestLocalResourceDirWithoutCmdNoServe(t *testing.T) {
    24  	f := newFixture(t)
    25  
    26  	f.file("Tiltfile", `
    27  local_resource("test", dir="./foo")
    28  `)
    29  	f.loadErrString("'dir' specified but 'cmd' is empty")
    30  }
    31  
    32  func TestLocalResourceServeDirWithoutServeCmd(t *testing.T) {
    33  	f := newFixture(t)
    34  
    35  	f.file("Tiltfile", `
    36  local_resource("test", cmd="echo hi", serve_dir="./foo")
    37  `)
    38  	f.loadErrString("'serve_dir' specified but 'serve_cmd' is empty")
    39  }
    40  
    41  func TestLocalResourceDirWithCmdWorks(t *testing.T) {
    42  	f := newFixture(t)
    43  
    44  	f.file("Tiltfile", `
    45  local_resource("test", cmd="echo hi", dir="./foo")
    46  `)
    47  	f.load()
    48  }
    49  
    50  func TestLocalResourceServeDirWithServeCmdWorks(t *testing.T) {
    51  	f := newFixture(t)
    52  
    53  	f.file("Tiltfile", `
    54  local_resource("test", serve_cmd="python server.py", serve_dir="./foo")
    55  `)
    56  	f.load()
    57  }