MCPcopy Index your code
hub / github.com/ddev/ddev / TestDdevStart

Function TestDdevStart

pkg/ddevapp/ddevapp_test.go:535–669  ·  view source on GitHub ↗

TestDdevStart tests the functionality that is called when "ddev start" is executed

(t *testing.T)

Source from the content-addressed store, hash-verified

533
534// TestDdevStart tests the functionality that is called when "ddev start" is executed
535func TestDdevStart(t *testing.T) {
536 assert := asrt.New(t)
537 app := &ddevapp.DdevApp{}
538
539 // Make sure this leaves us in the original test directory
540 testDir, _ := os.Getwd()
541 //nolint: errcheck
542 defer os.Chdir(testDir)
543
544 site := TestSites[0]
545 switchDir := site.Chdir()
546 defer switchDir()
547
548 runTime := util.TimeTrackC(fmt.Sprintf("%s DdevStart", site.Name))
549
550 err := app.Init(site.Dir)
551 assert.NoError(err)
552
553 err = app.Start()
554 assert.NoError(err)
555
556 t.Cleanup(func() {
557 err = app.Stop(true, false)
558 assert.NoError(err)
559 assert.False(dockerutil.NetworkExists("ddev-" + app.Name + "_default"))
560 })
561
562 // Make sure the -built Docker image exists before stop
563 webBuilt := app.WebImage + "-" + site.Name + "-built"
564 exists, err := dockerutil.ImageExistsLocally(webBuilt)
565 assert.NoError(err)
566 assert.True(exists)
567 dbBuilt := ddevImages.GetDBImage(app.Database.Type, app.Database.Version) + "-" + site.Name + "-built"
568 exists, err = dockerutil.ImageExistsLocally(dbBuilt)
569 assert.NoError(err)
570 assert.True(exists)
571
572 // Ensure .ddev/.ddev-docker-compose* exists inside .ddev site folder
573 composeFile := fileutil.FileExists(app.DockerComposeYAMLPath())
574 assert.True(composeFile)
575
576 for _, containerType := range []string{"web", "db"} {
577 containerName, err := constructContainerName(containerType, app)
578 assert.NoError(err)
579 check, err := testcommon.ContainerCheck(containerName, "running")
580 assert.NoError(err)
581 assert.True(check, "Container check on %s failed", containerType)
582 }
583
584 err = app.Stop(true, false)
585 assert.NoError(err)
586
587 // Make sure the -built Docker images do not exist after stop with removeData
588 for _, imageName := range []string{webBuilt, dbBuilt} {
589 exists, err = dockerutil.ImageExistsLocally(imageName)
590 assert.NoError(err)
591 assert.False(exists, "image %s should not have existed but still exists (while testing %s)", imageName, app.Name)
592 }

Callers

nothing calls this directly

Calls 15

InitMethod · 0.95
StartMethod · 0.95
StopMethod · 0.95
DockerComposeYAMLPathMethod · 0.95
CaptureLogsMethod · 0.95
TimeTrackCFunction · 0.92
NetworkExistsFunction · 0.92
ImageExistsLocallyFunction · 0.92
FileExistsFunction · 0.92
ContainerCheckFunction · 0.92
CaptureOutputToFileFunction · 0.92
CreateTmpDirFunction · 0.92

Tested by

no test coverage detected