From 5082aef494acc2de7f46c380a26cd5d5cf72b0d3 Mon Sep 17 00:00:00 2001 From: sfc-gh-ext-simba-jy Date: Tue, 19 Sep 2023 23:39:27 -0700 Subject: [PATCH] Added sample testing function --- lib/connection/result/result.js | 1 + test/unit/result_test.js | 49 +++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 test/unit/result_test.js diff --git a/lib/connection/result/result.js b/lib/connection/result/result.js index f71f57b97..232dadf27 100644 --- a/lib/connection/result/result.js +++ b/lib/connection/result/result.js @@ -53,6 +53,7 @@ function Result(options) { this._returnedRows = data.returned; this._totalRows = data.total; this._statementTypeId = data.statementTypeId; + Logger.getInstance().trace("The result.js is called. QueryId is:", this._queryId); // if no chunk headers were specified, but a query-result-master-key (qrmk) // was specified, build the chunk headers from the qrmk diff --git a/test/unit/result_test.js b/test/unit/result_test.js new file mode 100644 index 000000000..251999972 --- /dev/null +++ b/test/unit/result_test.js @@ -0,0 +1,49 @@ +const connOption = require("../integration/connectionOptions"); +const snowflake = require('snowflake-sdk'); +const assert = require('assert'); +const testUtil = require("../integration/testUtil"); + +snowflake.configure({logLevel:"TRACE"}); + +describe.only("test and log how many result.js called for each execution",function (){ + let connection = snowflake.createConnection(connOption.valid); + connection.connect( + function (err, conn) + { + if (err) + { + console.error('Unable to connect: ' + err.message); + } + else + { + console.log('Successfully connected to Snowflake'); + } + } + ) + + it('Run Select 1 query', function (done) + { + connection.execute({ + sqlText: "select 1", + complete: function (err, stmt) + { + testUtil.checkError(err); + var stream = stmt.streamRows(); + var rowCount = 0; + stream.on('data', function () + { + rowCount++; + }); + stream.on('error', function (err) + { + testUtil.checkError(err); + }); + stream.on('end', function () + { + done(); + }); + } + }); + }); +}) + \ No newline at end of file