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

Function TestGetPostgresDataDir

pkg/ddevapp/db_test.go:207–265  ·  view source on GitHub ↗

TestGetPostgresDataDir tests the GetPostgresDataDir function for correct directory paths

(t *testing.T)

Source from the content-addressed store, hash-verified

205
206// TestGetPostgresDataDir tests the GetPostgresDataDir function for correct directory paths
207func TestGetPostgresDataDir(t *testing.T) {
208 tests := []struct {
209 name string
210 dbType string
211 dbVersion string
212 expectedPath string
213 }{
214 {
215 name: "PostgreSQL 9",
216 dbType: nodeps.Postgres,
217 dbVersion: nodeps.Postgres9,
218 expectedPath: "/var/lib/postgresql/data",
219 },
220 {
221 name: "PostgreSQL 17",
222 dbType: nodeps.Postgres,
223 dbVersion: nodeps.Postgres17,
224 expectedPath: "/var/lib/postgresql/data",
225 },
226 {
227 name: "PostgreSQL 18",
228 dbType: nodeps.Postgres,
229 dbVersion: "18",
230 expectedPath: "/var/lib/postgresql",
231 },
232 {
233 name: "PostgreSQL 19",
234 dbType: nodeps.Postgres,
235 dbVersion: "19",
236 expectedPath: "/var/lib/postgresql",
237 },
238 {
239 name: "MySQL (should return empty)",
240 dbType: nodeps.MySQL,
241 dbVersion: nodeps.MySQL80,
242 expectedPath: "",
243 },
244 {
245 name: "MariaDB (should return empty)",
246 dbType: nodeps.MariaDB,
247 dbVersion: nodeps.MariaDB1011,
248 expectedPath: "",
249 },
250 }
251
252 for _, test := range tests {
253 t.Run(test.name, func(t *testing.T) {
254 app := &ddevapp.DdevApp{
255 Database: ddevapp.DatabaseDesc{
256 Type: test.dbType,
257 Version: test.dbVersion,
258 },
259 }
260
261 result := app.GetPostgresDataDir()
262 require.Equal(t, test.expectedPath, result, "Test case: %s", test.name)
263 })
264 }

Callers

nothing calls this directly

Calls 1

GetPostgresDataDirMethod · 0.95

Tested by

no test coverage detected