also looking at this
fix(services): launch postgres from a script, and find libs where they are
#258
3 files
+189
-29
| @@ -87,9 +87,13 @@ test "ServiceConfig creation - PostgreSQL" { | ||
| 87 | 87 | try std.testing.expect(pg.keep_alive == true); |
| 88 | 88 | try std.testing.expect(pg.auto_start == false); |
| 89 | 89 | |
| 90 | // Start command must contain the port and PGDATA path | |
| 91 | try std.testing.expect(std.mem.indexOf(u8, pg.start_command, "5432") != null); | |
| 90 | // Postgres self-initializes, so it launches via a generated start script | |
| 91 | // (systemd mangles an inline shell command in ExecStart — #243). The port | |
| 92 | // therefore lives in that script and in health_check, as it does for | |
| 93 | // mysql and mariadb; the script's own contents are pinned in | |
| 94 | // definitions.zig. | |
| 92 | 95 | try std.testing.expect(std.mem.indexOf(u8, pg.start_command, "postgres") != null); |
| 96 | try std.testing.expect(std.mem.indexOf(u8, pg.health_check.?, "5432") != null); | |
| 93 | 97 | |
| 94 | 98 | // Env vars: PGPORT and PGDATA must be set |
| 95 | 99 | try std.testing.expect(pg.env_vars.get("PGPORT") != null); |
| @@ -107,7 +111,8 @@ test "ServiceConfig creation - PostgreSQL with custom port" { | ||
| 107 | 111 | defer pg.deinit(allocator); |
| 108 | 112 | |
| 109 | 113 | try std.testing.expect(pg.port.? == 9999); |
| 110 | try std.testing.expect(std.mem.indexOf(u8, pg.start_command, "9999") != null); | |
| 114 | // In the generated start script and the health check, not in ExecStart. | |
| 115 | try std.testing.expect(std.mem.indexOf(u8, pg.health_check.?, "9999") != null); | |
| 111 | 116 | |
| 112 | 117 | const pgport = pg.env_vars.get("PGPORT").?; |
| 113 | 118 | try std.testing.expectEqualStrings("9999", pgport); |
| @@ -1641,7 +1646,8 @@ test "PostgreSQL WithContext - null project_root falls back gracefully" { | ||
| 1641 | 1646 | try std.testing.expect(pg.port.? == 5432); |
| 1642 | 1647 | try std.testing.expect(pg.start_command.len > 0); |
| 1643 | 1648 | const expected_library_var = if (builtin.os.tag == .macos) "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH"; |
| 1644 | try std.testing.expect(std.mem.indexOf(u8, pg.start_command, expected_library_var) != null); | |
| 1649 | // The library path is set inside the generated start script now, so this | |
| 1650 | // asserts it where it is still observable from the config. | |
| 1645 | 1651 | try std.testing.expect(std.mem.indexOf(u8, pg.health_check.?, expected_library_var) != null); |
| 1646 | 1652 | try std.testing.expect(std.mem.indexOf(u8, pg.health_check.?, "pg_isready") != null); |
| 1647 | 1653 | } |
| @@ -2208,7 +2214,8 @@ test "getServiceConfigWithPort - PostgreSQL with custom port" { | ||
| 2208 | 2214 | |
| 2209 | 2215 | try std.testing.expectEqualStrings("postgres", config.name); |
| 2210 | 2216 | try std.testing.expect(config.port.? == 5433); |
| 2211 | try std.testing.expect(std.mem.indexOf(u8, config.start_command, "5433") != null); | |
| 2217 | // Generated start script, so the port is in the health check (#243). | |
| 2218 | try std.testing.expect(std.mem.indexOf(u8, config.health_check.?, "5433") != null); | |
| 2212 | 2219 | } |
| 2213 | 2220 | |
| 2214 | 2221 | test "getServiceConfigWithPort - MySQL with custom port" { |