TestGetRelativeWorkingDirectory validates GetRelativeWorkingDirectory
(t *testing.T)
| 58 | |
| 59 | // TestGetRelativeWorkingDirectory validates GetRelativeWorkingDirectory |
| 60 | func TestGetRelativeWorkingDirectory(t *testing.T) { |
| 61 | assert := asrt.New(t) |
| 62 | |
| 63 | origDir, _ := os.Getwd() |
| 64 | app := &ddevapp.DdevApp{} |
| 65 | |
| 66 | site := TestSites[0] |
| 67 | |
| 68 | t.Cleanup(func() { |
| 69 | err := os.Chdir(origDir) |
| 70 | assert.NoError(err) |
| 71 | err = app.Stop(true, false) |
| 72 | assert.NoError(err) |
| 73 | _ = os.RemoveAll("one") |
| 74 | }) |
| 75 | // Make sure we have one app in existence |
| 76 | err := app.Init(site.Dir) |
| 77 | require.NoError(t, err) |
| 78 | err = os.MkdirAll(filepath.Join(app.AppRoot, "one", "two", "three", "four"), 0755) |
| 79 | require.NoError(t, err) |
| 80 | |
| 81 | testCases := []string{filepath.Join("one"), filepath.Join("one", "two"), filepath.Join("one", "two", "three"), filepath.Join("one", "two", "three", "four")} |
| 82 | for _, c := range testCases { |
| 83 | err = os.Chdir(filepath.Join(app.AppRoot, c)) |
| 84 | require.NoError(t, err) |
| 85 | relDir := app.GetRelativeWorkingDirectory() |
| 86 | assert.Equal(filepath.ToSlash(c), filepath.ToSlash(relDir)) |
| 87 | } |
| 88 | } |
nothing calls this directly
no test coverage detected