TestValidTestSite tests the TestSite struct behavior in the case of a valid configuration.
(t *testing.T)
| 66 | |
| 67 | // TestValidTestSite tests the TestSite struct behavior in the case of a valid configuration. |
| 68 | func TestValidTestSite(t *testing.T) { |
| 69 | assert := asrt.New(t) |
| 70 | ensureDdevBin() |
| 71 | origDir, _ := os.Getwd() |
| 72 | |
| 73 | // It's not ideal to copy/paste this archive around, but we don't actually care about the contents |
| 74 | // of the archive for this test, only that it exists and can be extracted. This should (knock on wood) |
| 75 | //not need to be updated over time. |
| 76 | site := TestSites[0] |
| 77 | |
| 78 | // If running this with GOTEST_SHORT we have to create the directory, tarball etc. |
| 79 | site.Name = t.Name() |
| 80 | _, _ = exec.RunCommand(DdevBin, []string{"stop", "-RO", site.Name}) |
| 81 | |
| 82 | t.Cleanup(func() { |
| 83 | _ = os.Chdir(origDir) |
| 84 | _, err := exec.RunCommand(DdevBin, []string{"delete", "-Oy", site.Name}) |
| 85 | assert.NoError(err) |
| 86 | site.Cleanup() |
| 87 | _, err = os.Stat(site.Dir) |
| 88 | assert.Error(err, "Could not stat temporary directory after cleanup") |
| 89 | }) |
| 90 | err := site.Prepare() |
| 91 | require.NoError(t, err, "Prepare() failed on TestSite.Prepare() site=%s, err=%v", site.Name, err) |
| 92 | |
| 93 | docroot := filepath.Join(site.Dir, site.Docroot) |
| 94 | dirStat, err := os.Stat(docroot) |
| 95 | assert.NoError(err, "Docroot exists after prepare()") |
| 96 | if err != nil { |
| 97 | t.Fatalf("Directory did not exist after prepare(): %s", docroot) |
| 98 | } |
| 99 | assert.True(dirStat.IsDir(), "Docroot is a directory") |
| 100 | |
| 101 | err = os.Chdir(site.Dir) |
| 102 | require.NoError(t, err) |
| 103 | |
| 104 | currentDir, _ := os.Getwd() |
| 105 | |
| 106 | assert.Equal(currentDir, site.Dir) |
| 107 | } |
| 108 | |
| 109 | // TestGetLocalHTTPResponse() brings up a project and hits a URL to get the response |
| 110 | func TestGetLocalHTTPResponse(t *testing.T) { |
nothing calls this directly
no test coverage detected