<commit_before>package com.im.lac.demo.services

import groovy.sql.Sql
import java.sql.Connection
import javax.sql.DataSource
import org.postgresql.ds.PGSimpleDataSource
import spock.lang.Shared
import spock.lang.Specification
import com.im.lac.demo.model.*

/**
 *
 * @author timbo
 */
class DbFileServiceSpec extends Specification {
    
    @Shared DataSource dataSource = createDataSource()
    @Shared DbFileService service = new DbFileService(dataSource, DbFileService.DEFAULT_TABLE_NAME + "_test")
    @Shared Sql db = new Sql(dataSource)
    @Shared DataItem[] item = new DataItem[1] 
    
    DataSource createDataSource() {
        PGSimpleDataSource ds = new PGSimpleDataSource()
        
        ds.serverName = System.getenv("CHEMCENTRAL_DB_SERVER") ?: 'localhost'
        ds.portNumber =  new Integer(System.getenv("CHEMCENTRAL_DB_PORT") ?: '5432')
        ds.databaseName = System.getenv("CHEMCENTRAL_DB_NAME") ?: 'chemcentral'
        ds.user = System.getenv("CHEMCENTRAL_DB_USERNAME") ?: 'chemcentral'
        ds.password =  System.getenv("CHEMCENTRAL_DB_PASSWORD") ?:  '<PASSWORD>'

        return ds;
    }
    // run before the first feature method
    def setupSpec() {
        try {
            db.execute 'DROP TABLE ' + service.tableName
        } catch (Exception e) { }// expected   
        service.createTables()
    }     
    
    // run after the last feature method
    def cleanupSpec() {
        // first delete so that our LOBs get deleted
        db.execute 'DELETE FROM ' + service.tableName<commit_msg>fixing tests for jenkins<commit_after>package com.im.lac.demo.services

import groovy.sql.Sql
import java.sql.Connection
import javax.sql.DataSource
import org.postgresql.ds.PGSimpleDataSource
import spock.lang.Shared
import spock.lang.Specification
import com.im.lac.demo.model.*

/**
 *
 * @author timbo
 */
class DbFileServiceSpec extends Specification {
    
    @Shared DataSource dataSource = createDataSource()
    @Shared DbFileService service = new DbFileService(dataSource, 'users_test.demo_files')
    @Shared Sql db = new Sql(dataSource)
    @Shared DataItem[] item = new DataItem[1]
    
    DataSource createDataSource() {
        
        String pw = System.getenv('LAC_TESTUSER_PASSWORD')
        if (pw == null) {
            throw new IllegalStateException("Environment variable LAC_TESTUSER_PASSWORD not defined")
        }
        
        PGSimpleDataSource ds = new PGSimpleDataSource()
        
        ds.serverName = System.getenv("CHEMCENTRAL_DB_SERVER") ?: 'localhost'
        ds.portNumber =  new Integer(System.getenv("CHEMCENTRAL_DB_PORT") ?: '5432')
        ds.databaseName = System.getenv("CHEMCENTRAL_DB_NAME") ?: 'chemcentral'
        ds.user = 'tester'
        ds.password =  pw

        return ds;
    }
    // run before the first feature method
    def setupSpec() {
        try {
            db.execute 'DROP TABLE ' + service.tableName
        } catch (Exception e) { }// expected   
        service.createTables()
    }     
    
    // run after the last feature method
    def cleanupSpec() {
        // first delete so that our LOBs get deleted
        db.execute 'DELETE FROM ' + service.tableName
{'fraction_non_alphanumeric': 0.09899434318038969, 'fraction_numerical': 0.0031426775612822125, 'mean_word_length': 2.8257211538461537, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '7325487', 'n_tokens_mistral': 970, 'n_tokens_neox': 936, 'n_words': 222}