File tree Expand file tree Collapse file tree 5 files changed +27
-3
lines changed
src/sonar-sql-plugin/src/test
java/org/sonar/plugins/sql/sensors Expand file tree Collapse file tree 5 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 11-- sample
2- SELECT * FROM test;
2+ SELECT * FROM sample .test order by 1 ;
3+
34
45SELECT name,name FROM test;
56/*
Original file line number Diff line number Diff line change 11-- sample
2- SELECT * FROM test;
2+ SELECT * FROM sample . test order by 1 ;
33SELECT name,name FROM test;
44/*
55end comment
Original file line number Diff line number Diff line change @@ -57,7 +57,27 @@ public void testPsSQL() throws IOException {
5757 SQLSensor s = new SQLSensor ();
5858 s .execute (ctxTester );
5959
60- Assert .assertEquals (0 , ctxTester .allIssues ().size ());
60+ Assert .assertEquals (2 , ctxTester .allIssues ().size ());
61+
62+ }
63+
64+ @ SuppressWarnings ("deprecation" )
65+ @ Test
66+ public void testMySQL () throws IOException {
67+ SensorContextTester ctxTester = SensorContextTester .create (folder .getRoot ());
68+ ctxTester .settings ().setProperty (Constants .PLUGIN_SQL_DIALECT , "mysql" );
69+ File baseFile = folder .newFile ("test.sql" );
70+ FileUtils .copyURLToFile (getClass ().getResource ("/mysql/sample1.sql" ), baseFile );
71+
72+ String contents = new String (Files .readAllBytes (baseFile .toPath ()));
73+ DefaultInputFile ti = new TestInputFileBuilder ("test" , "test.sql" ).initMetadata (contents ).setContents (contents )
74+ .setLanguage (Constants .languageKey ).build ();
75+ ctxTester .fileSystem ().add (ti );
76+
77+ SQLSensor s = new SQLSensor ();
78+ s .execute (ctxTester );
79+
80+ Assert .assertEquals (2 , ctxTester .allIssues ().size ());
6181
6282 }
6383
Original file line number Diff line number Diff line change 1+ SELECT * FROM sample .test order by 1 ;
Original file line number Diff line number Diff line change @@ -20,3 +20,5 @@ SET row_security = off;
2020
2121CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
2222
23+
24+ SELECT * FROM sample .test order by 1 ;
You can’t perform that action at this time.
0 commit comments