@@ -45,6 +45,48 @@ import {
4545
4646describe ( 'transformByQ' , function ( ) {
4747 let tempDir : string
48+ const validSctFile = `<?xml version="1.0" encoding="UTF-8"?>
49+ <tree>
50+ <instances>
51+ <ProjectModel>
52+ <entities>
53+ <sources>
54+ <DbServer vendor="oracle" name="sample.rds.amazonaws.com">
55+ </DbServer>
56+ </sources>
57+ <targets>
58+ <DbServer vendor="aurora_postgresql" />
59+ </targets>
60+ </entities>
61+ <relations>
62+ <server-node-location>
63+ <FullNameNodeInfoList>
64+ <nameParts>
65+ <FullNameNodeInfo typeNode="schema" nameNode="schema1"/>
66+ <FullNameNodeInfo typeNode="table" nameNode="table1"/>
67+ </nameParts>
68+ </FullNameNodeInfoList>
69+ </server-node-location>
70+ <server-node-location>
71+ <FullNameNodeInfoList>
72+ <nameParts>
73+ <FullNameNodeInfo typeNode="schema" nameNode="schema2"/>
74+ <FullNameNodeInfo typeNode="table" nameNode="table2"/>
75+ </nameParts>
76+ </FullNameNodeInfoList>
77+ </server-node-location>
78+ <server-node-location>
79+ <FullNameNodeInfoList>
80+ <nameParts>
81+ <FullNameNodeInfo typeNode="schema" nameNode="schema3"/>
82+ <FullNameNodeInfo typeNode="table" nameNode="table3"/>
83+ </nameParts>
84+ </FullNameNodeInfoList>
85+ </server-node-location>
86+ </relations>
87+ </ProjectModel>
88+ </instances>
89+ </tree>`
4890
4991 beforeEach ( async function ( ) {
5092 tempDir = ( await TestFolder . create ( ) ) . path
@@ -400,49 +442,7 @@ describe('transformByQ', function () {
400442 } )
401443
402444 it ( `WHEN validateMetadataFile on fully valid .sct file THEN passes validation` , async function ( ) {
403- const sampleFileContents = `<?xml version="1.0" encoding="UTF-8"?>
404- <tree>
405- <instances>
406- <ProjectModel>
407- <entities>
408- <sources>
409- <DbServer vendor="oracle" name="sample.rds.amazonaws.com">
410- </DbServer>
411- </sources>
412- <targets>
413- <DbServer vendor="aurora_postgresql" />
414- </targets>
415- </entities>
416- <relations>
417- <server-node-location>
418- <FullNameNodeInfoList>
419- <nameParts>
420- <FullNameNodeInfo typeNode="schema" nameNode="schema1"/>
421- <FullNameNodeInfo typeNode="table" nameNode="table1"/>
422- </nameParts>
423- </FullNameNodeInfoList>
424- </server-node-location>
425- <server-node-location>
426- <FullNameNodeInfoList>
427- <nameParts>
428- <FullNameNodeInfo typeNode="schema" nameNode="schema2"/>
429- <FullNameNodeInfo typeNode="table" nameNode="table2"/>
430- </nameParts>
431- </FullNameNodeInfoList>
432- </server-node-location>
433- <server-node-location>
434- <FullNameNodeInfoList>
435- <nameParts>
436- <FullNameNodeInfo typeNode="schema" nameNode="schema3"/>
437- <FullNameNodeInfo typeNode="table" nameNode="table3"/>
438- </nameParts>
439- </FullNameNodeInfoList>
440- </server-node-location>
441- </relations>
442- </ProjectModel>
443- </instances>
444- </tree>`
445- const isValidMetadata = await validateSQLMetadataFile ( sampleFileContents , { tabID : 'abc123' } )
445+ const isValidMetadata = await validateSQLMetadataFile ( validSctFile , { tabID : 'abc123' } )
446446 assert . strictEqual ( isValidMetadata , true )
447447 assert . strictEqual ( transformByQState . getSourceDB ( ) , DB . ORACLE )
448448 assert . strictEqual ( transformByQState . getTargetDB ( ) , DB . AURORA_POSTGRESQL )
@@ -454,96 +454,14 @@ describe('transformByQ', function () {
454454 } )
455455
456456 it ( `WHEN validateMetadataFile on .sct file with unsupported source DB THEN fails validation` , async function ( ) {
457- const sampleFileContents = `<?xml version="1.0" encoding="UTF-8"?>
458- <tree>
459- <instances>
460- <ProjectModel>
461- <entities>
462- <sources>
463- <DbServer vendor="not-oracle" name="sample.rds.amazonaws.com">
464- </DbServer>
465- </sources>
466- <targets>
467- <DbServer vendor="aurora_postgresql" />
468- </targets>
469- </entities>
470- <relations>
471- <server-node-location>
472- <FullNameNodeInfoList>
473- <nameParts>
474- <FullNameNodeInfo typeNode="schema" nameNode="schema1"/>
475- <FullNameNodeInfo typeNode="table" nameNode="table1"/>
476- </nameParts>
477- </FullNameNodeInfoList>
478- </server-node-location>
479- <server-node-location>
480- <FullNameNodeInfoList>
481- <nameParts>
482- <FullNameNodeInfo typeNode="schema" nameNode="schema2"/>
483- <FullNameNodeInfo typeNode="table" nameNode="table2"/>
484- </nameParts>
485- </FullNameNodeInfoList>
486- </server-node-location>
487- <server-node-location>
488- <FullNameNodeInfoList>
489- <nameParts>
490- <FullNameNodeInfo typeNode="schema" nameNode="schema3"/>
491- <FullNameNodeInfo typeNode="table" nameNode="table3"/>
492- </nameParts>
493- </FullNameNodeInfoList>
494- </server-node-location>
495- </relations>
496- </ProjectModel>
497- </instances>
498- </tree>`
499- const isValidMetadata = await validateSQLMetadataFile ( sampleFileContents , { tabID : 'abc123' } )
457+ const sctFileWithInvalidSource = validSctFile . replace ( 'oracle' , 'not-oracle' )
458+ const isValidMetadata = await validateSQLMetadataFile ( sctFileWithInvalidSource , { tabID : 'abc123' } )
500459 assert . strictEqual ( isValidMetadata , false )
501460 } )
502461
503462 it ( `WHEN validateMetadataFile on .sct file with unsupported target DB THEN fails validation` , async function ( ) {
504- const sampleFileContents = `<?xml version="1.0" encoding="UTF-8"?>
505- <tree>
506- <instances>
507- <ProjectModel>
508- <entities>
509- <sources>
510- <DbServer vendor="oracle" name="sample.rds.amazonaws.com">
511- </DbServer>
512- </sources>
513- <targets>
514- <DbServer vendor="not-postgresql" />
515- </targets>
516- </entities>
517- <relations>
518- <server-node-location>
519- <FullNameNodeInfoList>
520- <nameParts>
521- <FullNameNodeInfo typeNode="schema" nameNode="schema1"/>
522- <FullNameNodeInfo typeNode="table" nameNode="table1"/>
523- </nameParts>
524- </FullNameNodeInfoList>
525- </server-node-location>
526- <server-node-location>
527- <FullNameNodeInfoList>
528- <nameParts>
529- <FullNameNodeInfo typeNode="schema" nameNode="schema2"/>
530- <FullNameNodeInfo typeNode="table" nameNode="table2"/>
531- </nameParts>
532- </FullNameNodeInfoList>
533- </server-node-location>
534- <server-node-location>
535- <FullNameNodeInfoList>
536- <nameParts>
537- <FullNameNodeInfo typeNode="schema" nameNode="schema3"/>
538- <FullNameNodeInfo typeNode="table" nameNode="table3"/>
539- </nameParts>
540- </FullNameNodeInfoList>
541- </server-node-location>
542- </relations>
543- </ProjectModel>
544- </instances>
545- </tree>`
546- const isValidMetadata = await validateSQLMetadataFile ( sampleFileContents , { tabID : 'abc123' } )
463+ const sctFileWithInvalidTarget = validSctFile . replace ( 'aurora_postgresql' , 'not-postgresql' )
464+ const isValidMetadata = await validateSQLMetadataFile ( sctFileWithInvalidTarget , { tabID : 'abc123' } )
547465 assert . strictEqual ( isValidMetadata , false )
548466 } )
549467} )
0 commit comments