github.com/tilt-dev/tilt@v0.36.0/integration/ignores_test.go (about)

     1  //go:build integration
     2  // +build integration
     3  
     4  package integration
     5  
     6  import (
     7  	"context"
     8  	"net/http"
     9  	"testing"
    10  	"time"
    11  
    12  	"github.com/stretchr/testify/assert"
    13  )
    14  
    15  func TestIgnores(t *testing.T) {
    16  	f := newK8sFixture(t, "ignores")
    17  	f.TiltUp()
    18  
    19  	ctx, cancel := context.WithTimeout(f.ctx, time.Minute)
    20  	defer cancel()
    21  	_ = f.WaitForAllPodsReady(ctx, "app=ignores")
    22  
    23  	ctx, cancel = context.WithTimeout(f.ctx, time.Minute)
    24  	defer cancel()
    25  	f.CurlUntil(ctx, "http://localhost:31234", "🍄 One-Up! 🍄")
    26  
    27  	f.ReplaceContents("ignored_by_tiltfile.txt", "ignored", "updated")
    28  	f.ReplaceContents("ignored_by_dockerignore.txt", "ignored", "updated")
    29  	f.ReplaceContents("ignored_by_tiltignore.txt", "ignored", "updated")
    30  	f.ReplaceContents("compile.sh", "One-Up", "Two-Up")
    31  
    32  	ctx, cancel = context.WithTimeout(f.ctx, time.Minute)
    33  	defer cancel()
    34  	f.CurlUntil(ctx, "http://localhost:31234", "🍄 Two-Up! 🍄")
    35  
    36  	// The tiltignore'd file should be in the docker context, but
    37  	// should not be synced.
    38  	_, body, err := f.Curl("http://localhost:31234/ignored_by_tiltignore.txt")
    39  	assert.NoError(t, err)
    40  	assert.Contains(t, body, "should be ignored")
    41  
    42  	// The dockerignore'd and tiltfile ignored file should not be in the docker context,
    43  	// and not be synced.
    44  	res, err := http.Get("http://localhost:31234/ignored_by_dockerignore.txt")
    45  	assert.NoError(t, err)
    46  	assert.Equal(t, res.StatusCode, http.StatusNotFound)
    47  
    48  	res, err = http.Get("http://localhost:31234/ignored_by_tiltfile.txt")
    49  	assert.NoError(t, err)
    50  	assert.Equal(t, res.StatusCode, http.StatusNotFound)
    51  
    52  	_, body, err = f.Curl("http://localhost:31234/topdir/subdir/src.txt")
    53  	assert.NoError(t, err)
    54  	assert.Contains(t, body, "hello")
    55  }