"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
const constants_1 = require("../constants");
const lsp_server_1 = require("../lsp-server");
describe('Generate Preview Script Test', () => {
    const lspServer = new lsp_server_1.LSPServer();
    it('should replace with clause with file uri', () => {
        const uri = 'test://test.sql1';
        const content = `create TEMPORARY table t1 (a int) 
with ('connector' = 'datagen');

create TEMPORARY table t2 (a int) 
with ('connector' = 'blackhole');

insert into t2
    select 
        * 
    from
        t1;`;
        const textDocument = vscode_languageserver_textdocument_1.TextDocument.create(uri, constants_1.LANGUAGE_ID, 0, content);
        const previewContext = {
            sources: [
                {
                    catalogName: 'mysql',
                    databaseName: 'default',
                    tableName: 't1',
                    temporary: true,
                    uri: 'oss://some-url'
                }
            ],
            sinks: [
                {
                    catalogName: 'mysql',
                    databaseName: 'default',
                    temporary: true,
                    tableName: 't2'
                }
            ]
        };
        lspServer.warehouse.setParsingValue(textDocument);
        const script = lspServer.generatePreviewScript(textDocument, previewContext).trim();
        (0, chai_1.expect)(script).to.be.equal(`create TEMPORARY table t1 (a int) WITH (
  'connector' = 'filesystem',
  'path' = 'oss://some-url',
  'format' = 'csv'
);

create TEMPORARY table t2 (a int) WITH ( 'connector' = 'preview' );

insert into t2
    select 
        * 
    from
        t1;`);
    });
    it('should remove patitioned by clause', () => {
        const uri = 'test://test.sql2';
        const content = `create TEMPORARY table t1 (a int, b string) 
partitioned by (b)
with ('connector' = 'datagen');

create TEMPORARY table t2 (a int) 
with ('connector' = 'blackhole');

insert into t2
    select 
        * 
    from
        t1;`;
        const textDocument = vscode_languageserver_textdocument_1.TextDocument.create(uri, constants_1.LANGUAGE_ID, 0, content);
        const previewContext = {
            sources: [
                {
                    catalogName: 'mysql',
                    databaseName: 'default',
                    tableName: 't1',
                    temporary: true
                }
            ],
            sinks: [
                {
                    catalogName: 'mysql',
                    databaseName: 'default',
                    temporary: true,
                    tableName: 't2'
                }
            ]
        };
        lspServer.warehouse.setParsingValue(textDocument);
        const script = lspServer.generatePreviewScript(textDocument, previewContext).trim();
        (0, chai_1.expect)(script).to.be.equal(`create TEMPORARY table t1 (a int, b string)  
with ('connector' = 'datagen');

create TEMPORARY table t2 (a int) WITH ( 'connector' = 'preview' );

insert into t2
    select 
        * 
    from
        t1;`);
    });
});
//# sourceMappingURL=custom-command.test.js.map