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

Function TestDdevImportFiles

pkg/ddevapp/ddevapp_test.go:2763–2861  ·  view source on GitHub ↗

TestDdevImportFiles tests the functionality that is called when "ddev import-files" is executed

(t *testing.T)

Source from the content-addressed store, hash-verified

2761
2762// TestDdevImportFiles tests the functionality that is called when "ddev import-files" is executed
2763func TestDdevImportFiles(t *testing.T) {
2764 origDir, _ := os.Getwd()
2765 assert := asrt.New(t)
2766 app := &ddevapp.DdevApp{}
2767
2768 for i, site := range TestSites {
2769 if site.Disable {
2770 t.Logf("Skipping TestSite %s=%d because disabled", site.Name, i)
2771 continue
2772 }
2773
2774 if site.Type == "php" || (site.FilesTarballURL == "" && site.FilesZipballURL == "" && site.FullSiteTarballURL == "") {
2775 t.Logf("== SKIP TestDdevImportFiles for %s (FilesTarballURL and FilesZipballURL are not provided) or type php\n", site.Name)
2776 continue
2777 }
2778
2779 t.Logf("== BEGIN TestDdevImportFiles for %s\n", site.Name)
2780 runTime := util.TimeTrackC(fmt.Sprintf("%s %s", site.Name, t.Name()))
2781
2782 testcommon.ClearDockerEnv()
2783 err := app.Init(site.Dir)
2784 assert.NoError(err)
2785 t.Cleanup(func() {
2786 err = os.Chdir(origDir)
2787 assert.NoError(err)
2788 err = app.Stop(true, false)
2789 assert.NoError(err)
2790 })
2791 err = os.Chdir(site.Dir)
2792 require.NoError(t, err)
2793
2794 app.Hooks = map[string][]ddevapp.YAMLTask{"post-import-files": {{"exec-host": "touch hello-post-import-files-" + app.Name}}, "pre-import-files": {{"exec-host": "touch hello-pre-import-files-" + app.Name}}}
2795
2796 err = app.Start()
2797 require.NoError(t, err)
2798
2799 if site.FilesTarballURL != "" && app.GetUploadDir() != "" {
2800 _, tarballPath, err := testcommon.GetCachedArchive(site.Name, "local-tarballs-files", "", site.FilesTarballURL)
2801 assert.NoError(err)
2802 err = app.ImportFiles("", tarballPath, "")
2803 if err != nil {
2804 assert.NoError(err, "failed importing files tarball %s for site %s: %v", tarballPath, site.Name, err)
2805 continue
2806 }
2807 }
2808
2809 if site.FilesZipballURL != "" {
2810 _, zipballPath, err := testcommon.GetCachedArchive(site.Name, "local-zipballs-files", "", site.FilesZipballURL)
2811 assert.NoError(err)
2812 err = app.ImportFiles("", zipballPath, "")
2813 if err != nil {
2814 assert.NoError(err)
2815 continue
2816 }
2817 }
2818
2819 if site.FullSiteTarballURL != "" && site.FullSiteArchiveExtPath != "" {
2820 _, siteTarPath, err := testcommon.GetCachedArchive(site.Name, "local-site-tar", "", site.FullSiteTarballURL)

Callers

nothing calls this directly

Calls 13

InitMethod · 0.95
StopMethod · 0.95
StartMethod · 0.95
GetUploadDirMethod · 0.95
ImportFilesMethod · 0.95
ExecMethod · 0.95
GetContainerUploadDirMethod · 0.95
TimeTrackCFunction · 0.92
ClearDockerEnvFunction · 0.92
GetCachedArchiveFunction · 0.92
CleanupMethod · 0.80

Tested by

no test coverage detected