/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.opentable.db.postgres.embedded;

import static org.junit.Assert.assertEquals;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import org.junit.Rule;
import org.junit.Test;

import com.opentable.db.postgres.junit.EmbeddedPostgresRules;
import com.opentable.db.postgres.junit.PreparedDbRule;

public class FlywayPreparerTest {
    @Rule
    public PreparedDbRule db = EmbeddedPostgresRules.preparedDatabase(FlywayPreparer.forClasspathLocation("db/testing"));

    @Test
    public void testTablesMade() throws Exception {
        try (Connection c = db.getTestDatabase().getConnection();
                Statement s = c.createStatement()) {
            ResultSet rs = s.executeQuery("SELECT * FROM foo");
            rs.next();
            assertEquals("bar", rs.getString(1));
        }
    }
}

@@ -640,16 +640,75 @@
 tEquals;
+%0Aimport static org.junit.jupiter.api.Assertions.assertTrue;
 %0A%0Aimport
@@ -782,16 +782,64 @@
 atement;
+%0Aimport java.util.HashSet;%0Aimport java.util.Set;
 %0A%0Aimport
@@ -1357,16 +1357,21 @@
         
+try (
 ResultSe
@@ -1412,18 +1412,21 @@
 OM foo%22)
-;%0A
+) %7B%0A 
         
@@ -1429,16 +1429,19 @@
         
+   
 rs.next(
@@ -1439,24 +1439,28 @@
  rs.next();%0A
+    
             
@@ -1497,16 +1497,582 @@
 ng(1));%0A
+            %7D%0A            try (ResultSet rs = s.executeQuery(%22SELECT table_name%5Cn%22 +%0A                    %22  FROM information_schema.tables%5Cn%22 +%0A                    %22 WHERE table_schema='public'%5Cn%22 +%0A                    %22   AND table_type='BASE TABLE'%22)) %7B%0A                Set%3CString%3E tableNames = new HashSet%3C%3E();%0A                while(rs.next()) %7B%0A                    tableNames.add(rs.getString(1));%0A                %7D%0A                assertTrue(tableNames.contains(%22foo%22));%0A                assertTrue(tableNames.contains(%22flyway_schema_history%22));%0A            %7D%0A%0A%0A
         

improve test