hub-setup.test.mjs
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf
mirror: GitHub Phase A durable MCP OAuth (#270)
Human
minor
⚠ breaking
11 days ago
| 1 | /** |
| 2 | * Hub setup read/write tests. |
| 3 | */ |
| 4 | import { describe, it, after } from 'node:test'; |
| 5 | import assert from 'node:assert'; |
| 6 | import fs from 'fs'; |
| 7 | import path from 'path'; |
| 8 | import { fileURLToPath } from 'url'; |
| 9 | import { readHubSetup, writeHubSetup } from '../lib/hub-setup.mjs'; |
| 10 | |
| 11 | const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
| 12 | // Own directory so parallel runs do not race config.test.mjs on test/fixtures/data/hub_setup.yaml. |
| 13 | const dataDir = path.join(__dirname, 'fixtures', 'hub-setup-test-data'); |
| 14 | const hubSetupPath = path.join(dataDir, 'hub_setup.yaml'); |
| 15 | |
| 16 | function cleanup() { |
| 17 | try { fs.unlinkSync(hubSetupPath); } catch (_) {} |
| 18 | try { fs.rmdirSync(dataDir); } catch (_) {} |
| 19 | } |
| 20 | |
| 21 | describe('hub-setup', () => { |
| 22 | after(cleanup); |
| 23 | |
| 24 | it('readHubSetup returns null when file does not exist', () => { |
| 25 | cleanup(); |
| 26 | assert.strictEqual(readHubSetup(dataDir), null); |
| 27 | }); |
| 28 | |
| 29 | it('writeHubSetup creates file and readHubSetup reads it', () => { |
| 30 | cleanup(); |
| 31 | writeHubSetup(dataDir, { |
| 32 | vault: { git: { enabled: true, remote: 'https://github.com/u/r.git' } }, |
| 33 | }); |
| 34 | const read = readHubSetup(dataDir); |
| 35 | assert(read !== null); |
| 36 | assert.strictEqual(read.vault?.git?.enabled, true); |
| 37 | assert.strictEqual(read.vault?.git?.remote, 'https://github.com/u/r.git'); |
| 38 | }); |
| 39 | |
| 40 | it('writeHubSetup rejects empty vault_path', () => { |
| 41 | assert.throws( |
| 42 | () => writeHubSetup(dataDir, { vault_path: ' ' }), |
| 43 | /vault_path cannot be empty/ |
| 44 | ); |
| 45 | }); |
| 46 | |
| 47 | it('writeHubSetup merges with existing vault.git', () => { |
| 48 | cleanup(); |
| 49 | writeHubSetup(dataDir, { vault_path: './vault', vault: { git: { enabled: true, remote: 'https://a.git' } } }); |
| 50 | writeHubSetup(dataDir, { vault: { git: { remote: 'https://b.git' } } }); |
| 51 | const read = readHubSetup(dataDir); |
| 52 | assert.strictEqual(read?.vault_path, './vault'); |
| 53 | assert.strictEqual(read?.vault?.git?.enabled, true); |
| 54 | assert.strictEqual(read?.vault?.git?.remote, 'https://b.git'); |
| 55 | }); |
| 56 | }); |
File History
4 commits
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf
mirror: GitHub Phase A durable MCP OAuth (#270)
Human
minor
⚠
11 days ago
sha256:d8c648b20a4d53b2673c5c082ee7edfa7b2fc9b11080832da1f38807b6bf940b
fix(7C-L1b): route hosted delegation proposals through cani…
Human
minor
⚠
31 days ago
sha256:2827ba9e7632a4b141c50caf1e8f7d77abbc3515be20e7465f2bccb0ac4edf91
fix: repair endpoint now sets has_active_subscription when …
Human
minor
⚠
51 days ago
sha256:6a102aafafdfe7e70a24f4e59740200f0ee713ce7915f1b53e9d4ba5ee8b4410
Initial Muse snapshot
Human
83 days ago