TestGetPostgresDataPath tests the GetPostgresDataPath function for correct data file paths
(t *testing.T)
| 266 | |
| 267 | // TestGetPostgresDataPath tests the GetPostgresDataPath function for correct data file paths |
| 268 | func TestGetPostgresDataPath(t *testing.T) { |
| 269 | tests := []struct { |
| 270 | name string |
| 271 | dbType string |
| 272 | dbVersion string |
| 273 | expectedPath string |
| 274 | }{ |
| 275 | { |
| 276 | name: "PostgreSQL 9", |
| 277 | dbType: nodeps.Postgres, |
| 278 | dbVersion: nodeps.Postgres9, |
| 279 | expectedPath: "/var/lib/postgresql/data", |
| 280 | }, |
| 281 | { |
| 282 | name: "PostgreSQL 17", |
| 283 | dbType: nodeps.Postgres, |
| 284 | dbVersion: nodeps.Postgres17, |
| 285 | expectedPath: "/var/lib/postgresql/data", |
| 286 | }, |
| 287 | { |
| 288 | name: "PostgreSQL 18", |
| 289 | dbType: nodeps.Postgres, |
| 290 | dbVersion: nodeps.Postgres18, |
| 291 | expectedPath: "/var/lib/postgresql/18/docker", |
| 292 | }, |
| 293 | { |
| 294 | name: "MySQL (should return empty)", |
| 295 | dbType: nodeps.MySQL, |
| 296 | dbVersion: nodeps.MySQL80, |
| 297 | expectedPath: "", |
| 298 | }, |
| 299 | { |
| 300 | name: "MariaDB (should return empty)", |
| 301 | dbType: nodeps.MariaDB, |
| 302 | dbVersion: nodeps.MariaDB1011, |
| 303 | expectedPath: "", |
| 304 | }, |
| 305 | } |
| 306 | |
| 307 | for _, test := range tests { |
| 308 | t.Run(test.name, func(t *testing.T) { |
| 309 | app := &ddevapp.DdevApp{ |
| 310 | Database: ddevapp.DatabaseDesc{ |
| 311 | Type: test.dbType, |
| 312 | Version: test.dbVersion, |
| 313 | }, |
| 314 | } |
| 315 | |
| 316 | result := app.GetPostgresDataPath() |
| 317 | require.Equal(t, test.expectedPath, result, "Test case: %s", test.name) |
| 318 | }) |
| 319 | } |
| 320 | } |
nothing calls this directly
no test coverage detected