n8n/packages/nodes-base/nodes/Snowflake/__tests__/insert.test.ts
n8n-assistant[bot] aec110f198
Some checks are pending
CI: Master (Build, Test, Lint) / Build for Github Cache (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (22.x) (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (24.13.1) (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (25.x) (push) Waiting to run
CI: Master (Build, Test, Lint) / Lint (push) Waiting to run
CI: Master (Build, Test, Lint) / Performance (push) Waiting to run
CI: Master (Build, Test, Lint) / Notify Slack on failure (push) Blocked by required conditions
fix(Snowflake Node): Fix issue with Insert and Update operations not working (backport to 1.x) (#29812)
Co-authored-by: Jon <jonathan.bennetts@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 16:03:40 +00:00

49 lines
1.4 KiB
TypeScript

import { NodeTestHarness } from '@nodes-testing/node-test-harness';
const mockExecute = jest.fn();
const mockConnect = jest.fn();
const mockDestroy = jest.fn();
const mockConnection = { connect: mockConnect, execute: mockExecute, destroy: mockDestroy };
jest.mock('snowflake-sdk', () => ({
configure: jest.fn(),
createConnection: jest.fn().mockReturnValue(mockConnection),
}));
const snowflakeCredentials = {
authentication: 'password',
account: 'test-account',
database: 'TEST_DB',
schema: 'PUBLIC',
warehouse: 'WH',
role: 'SYSADMIN',
clientSessionKeepAlive: false,
username: 'user',
password: 'pass',
};
afterEach(() => jest.clearAllMocks());
describe('Test Snowflake, insert - parameter binding', () => {
mockConnect.mockImplementation((callback: (err: null) => void) => callback(null));
mockDestroy.mockImplementation((callback: (err: null) => void) => callback(null));
mockExecute.mockImplementation(
({ complete }: { complete: (err: null, stmt: undefined, rows: unknown[]) => void }) =>
complete(null, undefined, []),
);
new NodeTestHarness().setupTests({
workflowFiles: ['insert.workflow.json'],
credentials: { snowflake: snowflakeCredentials },
customAssertions() {
expect(mockExecute).toHaveBeenCalledTimes(1);
expect(mockExecute).toHaveBeenCalledWith(
expect.objectContaining({
sqlText: 'INSERT INTO "ORDERS" ("NAME","STATUS") VALUES (?,?)',
binds: [['Alice', 'active']],
}),
);
},
});
});