github.com/tilt-dev/tilt@v0.36.0/integration/ttl_job_test.go (about) 1 //go:build integration 2 // +build integration 3 4 package integration 5 6 import ( 7 "bytes" 8 "context" 9 "encoding/json" 10 "log" 11 "testing" 12 "time" 13 14 "github.com/stretchr/testify/assert" 15 16 "github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1" 17 ) 18 19 // Create a job with TTL cleanup. 20 // https://github.com/tilt-dev/tilt/issues/5949 21 func TestTTLJob(t *testing.T) { 22 f := newK8sFixture(t, "ttl_job") 23 24 f.TiltUp() 25 26 ctx, cancel := context.WithTimeout(f.ctx, 30*time.Second) 27 defer cancel() 28 29 f.WaitUntil(ctx, "failed to run job", func() (string, error) { 30 return f.logs.String(), nil 31 }, "ttl-job │ job-success") 32 33 f.WaitUntil(ctx, "failed to run local_resource", func() (string, error) { 34 return f.logs.String(), nil 35 }, "local │ success") 36 37 out, err := f.tilt.Get(ctx, "uiresource", "ttl-job") 38 assert.NoError(t, err) 39 40 log.Println(string(out)) 41 42 var resource v1alpha1.UIResource 43 err = json.NewDecoder(bytes.NewBuffer(out)).Decode(&resource) 44 assert.NoError(t, err) 45 assert.Equal(t, "ok", string(resource.Status.RuntimeStatus)) 46 }