github.com/tilt-dev/tilt@v0.36.0/integration/demo_test.go (about) 1 //go:build integration 2 // +build integration 3 4 package integration 5 6 import ( 7 "context" 8 "net/http" 9 "os" 10 "path/filepath" 11 "testing" 12 "time" 13 ) 14 15 func TestTiltDemo(t *testing.T) { 16 f := newFixture(t, "") 17 defer func() { 18 if !f.skipTiltDown { 19 // chdir to the sample project directory so that we can properly run a tilt down 20 // (this only happens if we did NOT make a cluster that got torn down so that we don't leave 21 // behind pods) 22 m, err := filepath.Glob(filepath.Join(f.dir, "*", "github.com", "tilt-dev", "tilt-avatars")) 23 if err != nil || len(m) != 1 { 24 t.Errorf("Could not find sample project: %v", err) 25 } 26 if err := os.Chdir(m[0]); err != nil { 27 t.Errorf("Could not chdir to sample project dir (%q): %v", m[0], err) 28 } 29 } 30 }() 31 32 var extraArgs []string 33 if dockerHost := os.Getenv("DOCKER_HOST"); dockerHost != "" { 34 // this is heavy-handed but sufficient for CI purposes 35 t.Logf("Detected non-default Docker configuration, will not attempt to create ephemeral K8s cluster (DOCKER_HOST=%s)", dockerHost) 36 extraArgs = append(extraArgs, "--no-cluster") 37 extraArgs = append(extraArgs, "--tmpdir", f.dir) 38 } else { 39 // we don't need to run tilt down because the entire temporary cluster will be destroyed 40 f.skipTiltDown = true 41 } 42 43 f.TiltDemo(extraArgs...) 44 45 ctx, cancel := context.WithTimeout(f.ctx, 3*time.Minute) 46 defer cancel() 47 48 f.CurlUntilStatusCode(ctx, "http://localhost:5734/ready", http.StatusNoContent) 49 }