test(core): cover base schema + respond; neutralize tunnel log prefix
This commit is contained in:
1 parent
dd99f4a47b
commit
df64404d21
4 files changed
+61
-3
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import * as z from 'zod'
|
||||
import { baseConnectionShape, sshConfigSchema } from '../../../src/config/baseSchema.js'
|
||||
|
||||
// A minimal concrete schema built from the shared base, the way a leaf package
|
||||
// would compose it.
|
||||
const testSchema = z.object({ ...baseConnectionShape, type: z.literal('test') }).strict()
|
||||
|
||||
describe('sshConfigSchema', () => {
|
||||
it('defaults port to 22', () => {
|
||||
expect(sshConfigSchema.parse({ host: 'h', user: 'u' }).port).toBe(22)
|
||||
})
|
||||
it('rejects unknown keys (strict)', () => {
|
||||
expect(() => sshConfigSchema.parse({ host: 'h', user: 'u', bogus: 1 })).toThrow()
|
||||
})
|
||||
})
|
||||
|
||||
describe('baseConnectionShape', () => {
|
||||
it('accepts a valid connection and defaults readonly to false', () => {
|
||||
const c = testSchema.parse({ name: 'c1', host: 'h', user: 'u', type: 'test' })
|
||||
expect(c.readonly).toBe(false)
|
||||
expect(c.port).toBeUndefined()
|
||||
})
|
||||
it('requires user', () => {
|
||||
expect(() => testSchema.parse({ name: 'c1', host: 'h', type: 'test' })).toThrow()
|
||||
})
|
||||
it('rejects an invalid name', () => {
|
||||
expect(() =>
|
||||
testSchema.parse({ name: 'bad name!', host: 'h', user: 'u', type: 'test' })
|
||||
).toThrow()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user