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