@@ -19,122 +19,10 @@ describe('AzureRmWebAppDeployment Suite', function() {
1919 if ( ! tl . exist ( path . join ( __dirname , '..' , 'node_modules/azure-pipelines-tasks-azure-arm-rest/Tests/node_modules' ) ) ) {
2020 tl . cp ( path . join ( __dirname , 'node_modules' ) , path . join ( __dirname , '..' , 'node_modules/azure-pipelines-tasks-azure-arm-rest/Tests' ) , '-rf' , true ) ;
2121 }
22-
23- tl . cp ( path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1XmlVarSub' , 'Web.config' ) , path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1XmlVarSub' , 'Web_test.config' ) , '-f' , false ) ;
24- tl . cp ( path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1XmlVarSub' , 'Web.Debug.config' ) , path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1XmlVarSub' , 'Web_test.Debug.config' ) , '-f' , false ) ;
25- tl . cp ( path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1XmlVarSub' , 'parameters.xml' ) , path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1XmlVarSub' , 'parameters_test.xml' ) , '-f' , false ) ;
26- tl . cp ( path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1XdtTransform' , 'Web.config' ) , path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1XdtTransform' , 'Web_test.config' ) , '-f' , false ) ;
2722 done ( ) ;
2823 } ) ;
29- after ( function ( ) {
30- try {
31- tl . rmRF ( path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1XmlVarSub' , 'parameters_test.xml' ) ) ;
32- }
33- catch ( error ) {
34- tl . debug ( error ) ;
35- }
36- } ) ;
3724
3825 ApplicationInsightsTests . ApplicationInsightsTests ( ) ;
3926 AppServiceTests . AzureAppServiceMockTests ( ) ;
4027 KuduServiceTests . KuduServiceTests ( ) ;
41-
42- if ( tl . osType ( ) . match ( / ^ W i n / ) ) {
43- it ( 'Runs successfully with XML Transformation (L1)' , ( done :MochaDone ) => {
44- this . timeout ( parseInt ( process . env . TASK_TEST_TIMEOUT ) || 20000 ) ;
45-
46- let tp = path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , "L1XdtTransform.js" ) ;
47- let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
48- tr . run ( ) ;
49-
50- var resultFile = ltx . parse ( fs . readFileSync ( path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1XdtTransform' , 'Web_test.config' ) ) ) ;
51- var expectFile = ltx . parse ( fs . readFileSync ( path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1XdtTransform' , 'Web_Expected.config' ) ) ) ;
52- assert ( ltx . equal ( resultFile , expectFile ) , 'Should Transform attributes on Web.config' ) ;
53- done ( ) ;
54- } ) ;
55- }
56- else {
57-
58- }
59-
60- it ( 'Runs successfully with XML variable substitution' , ( done :MochaDone ) => {
61- let tp = path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1XmlVarSub.js' ) ;
62- let tr = new ttm . MockTestRunner ( tp ) ;
63- tr . run ( ) ;
64- let transformedFilePath = path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1XmlVarSub' , 'Web_test.config' ) ;
65- let expectedFilePath = path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1XmlVarSub' , 'Web_Expected.config' ) ;
66- let transformedFileAsBuffer = fs . readFileSync ( transformedFilePath ) ;
67- let expectedFileAsBuffer = fs . readFileSync ( expectedFilePath ) ;
68- let transformedFileEncodeType = fileEncoding . detectFileEncoding ( transformedFilePath , transformedFileAsBuffer ) [ 0 ] ;
69- let transformedFileAsString = transformedFileAsBuffer . toString ( transformedFileEncodeType ) ;
70- transformedFileAsString = transformedFileAsString . replace ( / (?< ! \r ) [ \n ] + / gm, "\r\n" ) ;
71- transformedFileAsBuffer = Buffer . from ( transformedFileAsString , transformedFileEncodeType ) ;
72- var resultFile = ltx . parse ( transformedFileAsBuffer ) ;
73- var expectFile = ltx . parse ( expectedFileAsBuffer ) ;
74- assert ( ltx . equal ( resultFile , expectFile ) , 'Should have substituted variables in Web.config file' ) ;
75- transformedFilePath = path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1XmlVarSub' , 'Web_test.Debug.config' ) ;
76- expectedFilePath = path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1XmlVarSub' , 'Web_Expected.Debug.config' ) ;
77- transformedFileAsBuffer = fs . readFileSync ( transformedFilePath ) ;
78- expectedFileAsBuffer = fs . readFileSync ( expectedFilePath ) ;
79- transformedFileEncodeType = fileEncoding . detectFileEncoding ( transformedFilePath , transformedFileAsBuffer ) [ 0 ] ;
80- transformedFileAsString = transformedFileAsBuffer . toString ( transformedFileEncodeType ) ;
81- transformedFileAsString = transformedFileAsString . replace ( / (?< ! \r ) [ \n ] + / gm, "\r\n" ) ;
82- transformedFileAsBuffer = Buffer . from ( transformedFileAsString , transformedFileEncodeType ) ;
83- var resultFile = ltx . parse ( transformedFileAsBuffer ) ;
84- var expectFile = ltx . parse ( expectedFileAsBuffer ) ;
85- assert ( ltx . equal ( resultFile , expectFile ) , 'Should have substituted variables in Web.Debug.config file' ) ;
86- var resultParamFile = ltx . parse ( fs . readFileSync ( path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1XmlVarSub' , 'parameters_test.xml' ) ) ) ;
87- var expectParamFile = ltx . parse ( fs . readFileSync ( path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1XmlVarSub' , 'parameters_Expected.xml' ) ) ) ;
88- assert ( ltx . equal ( resultParamFile , expectParamFile ) , 'Should have substituted variables in parameters.xml file' ) ;
89- done ( ) ;
90- } ) ;
91-
92- it ( 'Runs successfully with JSON variable substitution' , ( done :MochaDone ) => {
93- let tp = path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1JsonVarSub.js' ) ;
94- let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
95- tr . run ( ) ;
96-
97- assert ( tr . stdout . search ( 'JSON - eliminating object variables validated' ) > 0 , 'JSON - eliminating object variables validation error' ) ;
98- assert ( tr . stdout . search ( 'JSON - simple string change validated' ) > 0 , 'JSON -simple string change validation error' ) ;
99- assert ( tr . stdout . search ( 'JSON - system variable elimination validated' ) > 0 , 'JSON -system variable elimination validation error' ) ;
100- assert ( tr . stdout . search ( 'JSON - special variables validated' ) > 0 , 'JSON - special variables validation error' ) ;
101- assert ( tr . stdout . search ( 'JSON - variables with dot character validated' ) > 0 , 'JSON variables with dot character validation error' ) ;
102- assert ( tr . stdout . search ( 'JSON - substitute inbuilt JSON attributes validated' ) > 0 , 'JSON inbuilt variable substitution validation error' ) ;
103- assert ( tr . stdout . search ( 'VALID JSON COMMENTS TESTS PASSED' ) > 0 , 'VALID JSON COMMENTS TESTS PASSED' ) ;
104- assert ( tr . stdout . search ( 'INVALID JSON COMMENTS TESTS PASSED' ) > 0 , 'INVALID JSON COMMENTS TESTS PASSED' ) ;
105- assert ( tr . succeeded , 'task should have succeeded' ) ;
106- done ( ) ;
107- } ) ;
108-
109- it ( 'Validate File Encoding' , ( done :MochaDone ) => {
110- let tp = path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L1ValidateFileEncoding.js' ) ;
111- let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
112- tr . run ( ) ;
113-
114- assert ( tr . stdout . search ( 'UTF-8 with BOM validated' ) >= 0 , 'Should have validated UTF-8 with BOM' ) ;
115- assert ( tr . stdout . search ( 'UTF-16LE with BOM validated' ) >= 0 , 'Should have validated UTF-16LE with BOM' ) ;
116- assert ( tr . stdout . search ( 'UTF-16BE with BOM validated' ) >= 0 , 'Should have validated UTF-16BE with BOM' ) ;
117- assert ( tr . stdout . search ( 'UTF-32LE with BOM validated' ) >= 0 , 'Should have validated UTF-32LE with BOM' ) ;
118- assert ( tr . stdout . search ( 'UTF-32BE with BOM validated' ) >= 0 , 'Should have validated UTF-32BE with BOM' ) ;
119-
120- assert ( tr . stdout . search ( 'UTF-8 without BOM validated' ) >= 0 , 'Should have validated UTF-8 without BOM' ) ;
121- assert ( tr . stdout . search ( 'UTF-16LE without BOM validated' ) >= 0 , 'Should have validated UTF-16LE without BOM' ) ;
122- assert ( tr . stdout . search ( 'UTF-16BE without BOM validated' ) >= 0 , 'Should have validated UTF-16BE without BOM' ) ;
123- assert ( tr . stdout . search ( 'UTF-32LE without BOM validated' ) >= 0 , 'Should have validated UTF-32LE without BOM' ) ;
124- assert ( tr . stdout . search ( 'UTF-32BE without BOM validated' ) >= 0 , 'Should have validated UTF-32BE without BOM' ) ;
125-
126- assert ( tr . stdout . search ( 'Short File Buffer Error' ) >= 0 , 'Should have validated short Buffer' ) ;
127- assert ( tr . stdout . search ( 'Unknown encoding type' ) >= 0 , 'Should throw for Unknown File Buffer' ) ;
128- done ( ) ;
129- } ) ;
130-
131- it ( 'Validate webdeployment-common.utility.copyDirectory()' , ( done :MochaDone ) => {
132- let tp = path . join ( __dirname , ".." , "node_modules" , "azure-pipelines-tasks-webdeployment-common" , "Tests" , 'L0CopyDirectory.js' ) ;
133- let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
134- tr . run ( ) ;
135-
136- assert ( tr . stdout . search ( '## Copy Files Successful ##' ) >= 0 , 'should have copied the files' ) ;
137- assert ( tr . stdout . search ( '## mkdir Successful ##' ) >= 0 , 'should have created dir including dest folder' ) ;
138- done ( ) ;
139- } ) ;
14028} ) ;
0 commit comments