MCPcopy Create free account
hub / github.com/ddev/ddev / TestDetectAppType

Function TestDetectAppType

pkg/ddevapp/apptypes_test.go:22–58  ·  view source on GitHub ↗

TestDetectAppType does a simple test of various filesystem setups to make sure the expected apptype is returned.

(t *testing.T)

Source from the content-addressed store, hash-verified

20// TestDetectAppType does a simple test of various filesystem setups to make
21// sure the expected apptype is returned.
22func TestDetectAppType(t *testing.T) {
23 origDir, _ := os.Getwd()
24 appTypes := ddevapp.GetValidAppTypes()
25 var notSimplePHPAppTypes = []string{}
26 for _, t := range appTypes {
27 // we don't detect "generic", "php", "drupal" app types
28 // They can't be "detected" anyway
29 if t != nodeps.AppTypePHP && t != nodeps.AppTypeDrupal && t != nodeps.AppTypeGeneric {
30 notSimplePHPAppTypes = append(notSimplePHPAppTypes, t)
31 }
32 }
33 tmpDir := testcommon.CreateTmpDir(t.Name())
34
35 t.Cleanup(func() {
36 _ = os.Chdir(origDir)
37 _ = os.RemoveAll(tmpDir)
38 })
39
40 err := fileutil.CopyDir(filepath.Join(origDir, "testdata", t.Name()), filepath.Join(tmpDir, "sampleapptypes"))
41 require.NoError(t, err)
42 for _, appType := range notSimplePHPAppTypes {
43 app, err := ddevapp.NewApp(filepath.Join(tmpDir, "sampleapptypes", appType), true)
44 require.NoError(t, err)
45 app.Docroot = ddevapp.DiscoverDefaultDocroot(app)
46 t.Cleanup(func() {
47 _ = app.Stop(true, false)
48 })
49
50 foundType := app.DetectAppType()
51 require.EqualValues(t, appType, foundType)
52
53 // `generic` type should not be overridden
54 app.Type = nodeps.AppTypeGeneric
55 foundType = app.DetectAppType()
56 require.EqualValues(t, nodeps.AppTypeGeneric, foundType)
57 }
58}
59
60// TestConfigOverrideAction tests that the ConfigOverride action is properly applied, but only if the
61// config is not included in the config.yaml.

Callers

nothing calls this directly

Calls 9

GetValidAppTypesFunction · 0.92
CreateTmpDirFunction · 0.92
CopyDirFunction · 0.92
NewAppFunction · 0.92
DiscoverDefaultDocrootFunction · 0.92
CleanupMethod · 0.80
ChdirMethod · 0.80
StopMethod · 0.80
DetectAppTypeMethod · 0.80

Tested by

no test coverage detected