Skip to content

Commit 3bedeb0

Browse files
committed
Multiple test improvements
1 parent 379d565 commit 3bedeb0

6 files changed

Lines changed: 36 additions & 10 deletions

packages/cli/src/commands/integrations/tests/add-integration.clickhouse.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import crypto from 'node:crypto'
2+
import { existsSync } from 'node:fs'
23
import { mkdir, readFile, rm } from 'node:fs/promises'
34
import { tmpdir } from 'node:os'
45
import { join } from 'node:path'
@@ -142,6 +143,8 @@ describe('add-integration clickhouse', () => {
142143
user: ch-user
143144
"
144145
`)
146+
147+
expect(existsSync(envFilePath)).toBe(false)
145148
})
146149

147150
it('creates clickhouse integration with SSH tunnel enabled', async () => {

packages/cli/src/commands/integrations/tests/add-integration.mindsdb.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ describe('add-integration mindsdb', () => {
179179
`)
180180
})
181181

182-
it('creates integration with SSL enabled', async () => {
182+
it('creates mindsdb integration with SSL enabled', async () => {
183183
const filePath = join(tempDir, 'integrations-ssl.yaml')
184184
const envFilePath = join(tempDir, '.env')
185185
const mockUUID: crypto.UUID = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'

packages/cli/src/commands/integrations/tests/add-integration.mysql.test.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ describe('add-integration mysql', () => {
179179
`)
180180
})
181181

182-
it('creates integration with SSL enabled', async () => {
182+
it('creates mysql integration with SSL enabled', async () => {
183183
const filePath = join(tempDir, 'integrations-ssl.yaml')
184184
const envFilePath = join(tempDir, '.env')
185185
const mockUUID: crypto.UUID = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
@@ -204,14 +204,12 @@ describe('add-integration mysql', () => {
204204

205205
await screen.next()
206206
expect(screen.getScreen()).toContain('CA Certificate:')
207-
screen.type('cert-content-here')
207+
screen.type('placeholder')
208208
screen.keypress('enter')
209209

210210
await promise
211211

212212
const yamlContent = await readFile(filePath, 'utf-8')
213-
const envContent = await readFile(envFilePath, 'utf-8')
214-
215213
expect(yamlContent).toMatchInlineSnapshot(`
216214
"#yaml-language-server: $schema=https://raw.githubusercontent.com/deepnote/deepnote/refs/heads/tk/integrations-config-file-schema/json-schemas/integrations-file-schema.json
217215
@@ -230,10 +228,18 @@ describe('add-integration mysql', () => {
230228
caCertificateText: env:AAAAAAAA_BBBB_CCCC_DDDD_EEEEEEEEEEEE__CACERTIFICATETEXT
231229
"
232230
`)
233-
expect(envContent).toMatchInlineSnapshot(`
234-
"AAAAAAAA_BBBB_CCCC_DDDD_EEEEEEEEEEEE__PASSWORD=supersecret
235-
AAAAAAAA_BBBB_CCCC_DDDD_EEEEEEEEEEEE__CACERTIFICATETEXT=cert-content-here
236-
"
237-
`)
231+
232+
// Verify multiline values survive the updateDotEnv → readDotEnv roundtrip.
233+
// screen.type() cannot inject literal newlines (they act as Enter/submit),
234+
// so we write a multiline cert value directly and verify it parses back.
235+
const { updateDotEnv, readDotEnv } = await import('../../../utils/dotenv')
236+
const multilineCert = 'line-1-of-cert\nline-2-of-cert\nline-3-of-cert'
237+
await updateDotEnv(envFilePath, {
238+
AAAAAAAA_BBBB_CCCC_DDDD_EEEEEEEEEEEE__CACERTIFICATETEXT: multilineCert,
239+
})
240+
241+
const parsedEnv = await readDotEnv(envFilePath)
242+
expect(parsedEnv.AAAAAAAA_BBBB_CCCC_DDDD_EEEEEEEEEEEE__PASSWORD).toBe('supersecret')
243+
expect(parsedEnv.AAAAAAAA_BBBB_CCCC_DDDD_EEEEEEEEEEEE__CACERTIFICATETEXT).toBe(multilineCert)
238244
})
239245
})

packages/cli/src/commands/integrations/tests/add-integration.pgsql.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ describe('add-integration pgsql', () => {
152152
await promise
153153

154154
const yamlContent = await readFile(filePath, 'utf-8')
155+
const envContent = await readFile(envFilePath, 'utf-8')
155156

156157
expect(yamlContent).toMatchInlineSnapshot(`
157158
"#yaml-language-server: $schema=https://raw.githubusercontent.com/deepnote/deepnote/refs/heads/tk/integrations-config-file-schema/json-schemas/integrations-file-schema.json
@@ -173,6 +174,10 @@ describe('add-integration pgsql', () => {
173174
password: env:NEW_UUID_1234_5678_ABCD1234ABCD__PASSWORD
174175
"
175176
`)
177+
expect(envContent).toMatchInlineSnapshot(`
178+
"NEW_UUID_1234_5678_ABCD1234ABCD__PASSWORD=new-pass
179+
"
180+
`)
176181
})
177182

178183
it('creates integration with SSH tunnel enabled', async () => {

packages/cli/src/commands/integrations/tests/add-integration.sql-server.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ describe('add-integration sql-server', () => {
146146
await promise
147147

148148
const yamlContent = await readFile(filePath, 'utf-8')
149+
const envContent = await readFile(envFilePath, 'utf-8')
150+
149151
expect(yamlContent).toMatchInlineSnapshot(`
150152
"#yaml-language-server: $schema=https://raw.githubusercontent.com/deepnote/deepnote/refs/heads/tk/integrations-config-file-schema/json-schemas/integrations-file-schema.json
151153
@@ -165,5 +167,9 @@ describe('add-integration sql-server', () => {
165167
sshUser: tunnel-user
166168
"
167169
`)
170+
expect(envContent).toMatchInlineSnapshot(`
171+
"AAAAAAAA_BBBB_CCCC_DDDD_EEEEEEEEEEEE__PASSWORD=supersecret
172+
"
173+
`)
168174
})
169175
})

packages/cli/src/commands/integrations/tests/edit-integration.sql-server.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ integrations:
9898
password: env:ID001__PASSWORD
9999
"
100100
`)
101+
102+
const envContent = await readFile(envFilePath, 'utf-8')
103+
expect(envContent).toMatchInlineSnapshot(`
104+
"ID001__PASSWORD=secret-pass
105+
"
106+
`)
101107
})
102108

103109
it('updates host and database when user types new values', async () => {

0 commit comments

Comments
 (0)