<commit_before>package com.socrata.pg.store

import org.scalatest.{BeforeAndAfterAll, FunSuite}
import org.scalatest.matchers.MustMatchers
import org.scalatest.prop.PropertyChecks
import java.sql.{DriverManager, Connection}
import com.rojoma.simplearm.util._
import com.socrata.soql.types.{SoQLValue, SoQLType}
import com.socrata.datacoordinator.id.{CopyId, DatasetId}
import com.socrata.datacoordinator.truth.metadata.{CopyPair, CopyInfo, LifecycleStage, DatasetInfo}
import com.socrata.datacoordinator.secondary.LifecycleStage
import com.socrata.datacoordinator.common.{StandardDatasetMapLimits, DataSourceConfig, DataSourceFromConfig, DatabaseCreator}
import com.socrata.datacoordinator.truth.sql.DatabasePopulator


/**
 *
 */
class PGSecondaryUniverseTest extends FunSuite with MustMatchers with BeforeAndAfterAll {
    type CT = SoQLType
    type CV = SoQLValue
    val common = PostgresUniverseCommon
    override def beforeAll() {
    }

    override def afterAll() {
    }

    def withDB[T]()(f: Connection => T): T = {
      using(DriverManager.getConnection("jdbc:h2:mem:")) { conn =>
        conn.setAutoCommit(false)
        f(conn)
      }
    }

    test("Universe can create a table") {
      withDB() { conn =>
        //for {
        //  dsInfo <- DataSourceFromConfig(new DataSourceConfig(config, "com.socrata.coordinator.backup.receiver.database"))
        //  conn <- managed(dsInfo.dataSource.getConnection())
        //} {
        //  DatabasePopulator.populate(conn, StandardDatasetMapLimits)
        //}

        val pgu = new PGSecondaryUniverse[CT, CV](conn,  PostgresUniverseCommon )<commit_msg>use local postgres secondary_test db for PGSecondaryUniverseTest.<commit_after>package com.socrata.pg.store

import org.scalatest.{BeforeAndAfterAll, FunSuite}
import org.scalatest.matchers.MustMatchers
import org.scalatest.prop.PropertyChecks
import java.sql.{DriverManager, Connection}
import com.rojoma.simplearm.util._
import com.socrata.soql.types.{SoQLValue, SoQLType}
import com.socrata.datacoordinator.id.{CopyId, DatasetId}
import com.socrata.datacoordinator.truth.metadata.{CopyPair, CopyInfo, LifecycleStage, DatasetInfo}
import com.socrata.datacoordinator.secondary.LifecycleStage
import com.socrata.datacoordinator.common.{StandardDatasetMapLimits, DataSourceConfig, DataSourceFromConfig, DatabaseCreator}
import com.socrata.datacoordinator.truth.sql.{DatasetMapLimits, DatabasePopulator}


/**
 *
 */
class PGSecondaryUniverseTest extends FunSuite with MustMatchers with BeforeAndAfterAll {
    type CT = SoQLType
    type CV = SoQLValue
    val common = PostgresUniverseCommon
    override def beforeAll() {
    }

    override def afterAll() {
    }

    def populateDatabase(conn: Connection) {
      val sql = DatabasePopulator.metadataTablesCreate(DatasetMapLimits())
      using(conn.createStatement()) { stmt =>
        stmt.execute(sql)
      }
    }

    def withDb[T]()(f: (Connection) => T): T = {
      using(DriverManager.getConnection("jdbc:postgresql://localhost:5432/secondary_test", "blist", "blist")) { conn =>
        conn.setAutoCommit(false)
        populateDatabase(conn)
        f(conn)
      }
    }

    test("Universe can create a table") {
      withDb() { conn =>
        val pgu = new PGSecondaryUniverse[CT, CV](conn,  PostgresUniverseCommon )
{'fraction_non_alphanumeric': 0.10631229235880399, 'fraction_numerical': 0.0015101177891875567, 'mean_word_length': 4.1269349845201235, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5453941', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1032, 'n_words': 186}