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

Function TestDrupalAppTypeUsage

cmd/ddev/cmd/config_test.go:815–886  ·  view source on GitHub ↗

TestDrupalAppTypeUsage validates that `drupal` project type gets used properly * It should be accepted, but turned into latest stable drupal version when `ddev config` * "drupal" in config.yaml type should be interpreted as latets stable drupal by ddev list and describe * `ddev config --auto` should

(t *testing.T)

Source from the content-addressed store, hash-verified

813// * "drupal" in config.yaml type should be interpreted as latets stable drupal by ddev list and describe
814// * `ddev config --auto` should respect `drupal` as project type but convert it to latest stable
815func TestDrupalAppTypeUsage(t *testing.T) {
816 origDir, _ := os.Getwd()
817
818 // Create a temporary directory and switch to it.
819 tmpDir := testcommon.CreateTmpDir(t.Name())
820 _ = os.Chdir(tmpDir)
821
822 out, err := exec.RunCommand(DdevBin, []string{"delete", "-Oy", t.Name()})
823 require.NoError(t, err, "ddev delete -Oy failed: %v", out)
824
825 t.Cleanup(func() {
826 _ = os.Chdir(origDir)
827 out, _ = exec.RunCommand(DdevBin, []string{"delete", "-Oy", t.Name()})
828 t.Logf("ddev delete -Oy %s output=%s", t.Name(), out)
829 _ = os.RemoveAll(tmpDir)
830 })
831
832 // Create a config
833 args := []string{"config", "--project-name=" + t.Name(), "--project-type=drupal"}
834 _, err = exec.RunCommand(DdevBin, args)
835 require.NoError(t, err)
836
837 app, err := ddevapp.NewApp(tmpDir, true)
838 require.NoError(t, err)
839
840 require.Equal(t, nodeps.AppTypeDrupalLatestStable, app.Type)
841 err = app.Start()
842 require.NoError(t, err)
843 t.Cleanup(func() {
844 _ = app.Stop(true, false)
845 })
846 desc, err := app.Describe(true)
847 require.NoError(t, err)
848 require.Equal(t, nodeps.AppTypeDrupalLatestStable, desc["type"])
849
850 err = app.Stop(true, false)
851 require.NoError(t, err)
852
853 // Just read the config and verify that the project type is the explicit drupal version
854 app, err = ddevapp.NewApp(tmpDir, true)
855 require.NoError(t, err)
856 require.Equal(t, nodeps.AppTypeDrupalLatestStable, app.Type)
857
858 err = app.Stop(true, false)
859 require.NoError(t, err)
860
861 // Now try type = "drupal" in the config.yaml and verify that we actually get latest stable
862 // legacy projects from late DDEV v1.23.x will have this.
863 app.Type = `drupal`
864 err = app.WriteConfig()
865 require.NoError(t, err)
866
867 err = app.Start()
868 require.NoError(t, err)
869
870 // Even though the config.yaml says "drupal", we'll report latest stable here
871 require.Equal(t, nodeps.AppTypeDrupalLatestStable, app.Type)
872

Callers

nothing calls this directly

Calls 11

CreateTmpDirFunction · 0.92
RunCommandFunction · 0.92
NewAppFunction · 0.92
RunHostCommandFunction · 0.92
ChdirMethod · 0.80
CleanupMethod · 0.80
StartMethod · 0.80
StopMethod · 0.80
DescribeMethod · 0.80
WriteConfigMethod · 0.80
ReadConfigMethod · 0.65

Tested by

no test coverage detected