|
1 | 1 | import { describe, expect, test, beforeEach, afterEach } from "bun:test"; |
2 | | -import { mkdtempSync, rmSync, writeFileSync, readFileSync } from "node:fs"; |
| 2 | +import { existsSync, mkdtempSync, rmSync, writeFileSync, readFileSync } from "node:fs"; |
3 | 3 | import { spawnSync } from "node:child_process"; |
4 | 4 | import { tmpdir } from "node:os"; |
5 | 5 | import { dirname, join } from "node:path"; |
@@ -101,6 +101,31 @@ describe("injectCodexConfig integration (Design B)", () => { |
101 | 101 | expect(config).not.toContain("# Auto-injected by opencodex\nopenai_base_url"); |
102 | 102 | }); |
103 | 103 |
|
| 104 | + test("external model provider stays byte-for-byte unchanged so its session history remains visible", () => { |
| 105 | + const original = [ |
| 106 | + 'model_provider = "custom"', |
| 107 | + 'model = "third-party-model"', |
| 108 | + "", |
| 109 | + "[model_providers.custom]", |
| 110 | + 'name = "Provider Manager"', |
| 111 | + 'base_url = "https://gateway.example/v1"', |
| 112 | + 'wire_api = "responses"', |
| 113 | + "requires_openai_auth = true", |
| 114 | + "", |
| 115 | + ].join("\n"); |
| 116 | + writeFileSync(join(codexHome, "config.toml"), original, "utf8"); |
| 117 | + |
| 118 | + const r = runInject(codexHome, ocxHome); |
| 119 | + expect(r.status).toBe(0); |
| 120 | + const result = JSON.parse(r.stdout); |
| 121 | + expect(result.success).toBe(true); |
| 122 | + expect(result.message).toContain("routing NOT injected"); |
| 123 | + expect(result.message).toContain('external model_provider "custom"'); |
| 124 | + |
| 125 | + expect(readFileSync(join(codexHome, "config.toml"), "utf8")).toBe(original); |
| 126 | + expect(existsSync(join(codexHome, "opencodex.config.toml"))).toBe(false); |
| 127 | + }); |
| 128 | + |
104 | 129 | test("non-loopback hostname still uses the legacy provider-table injection", () => { |
105 | 130 | writeFileSync(join(codexHome, "config.toml"), 'model = "gpt-5.5"\n', "utf8"); |
106 | 131 |
|
|
0 commit comments