<commit_before>#!/usr/bin/env bash

. ${BUILDPACK_TEST_RUNNER_HOME}/lib/test_utils.sh
. ${BUILDPACK_HOME}/opt/jdbc.sh

testDefaultEnvVar() {
    set_jdbc_url "postgres://foo:bar@ec2-0-0-0-0:5432/abc123"
    assertEquals "Wrong JDBC_DATABASE_URL" \
                 "jdbc:postgresql://ec2-0-0-0-0:5432/abc123?user=foo&password=bar&sslmode=require" \
                 "$JDBC_DATABASE_URL"
    unset JDBC_DATABASE_URL
}

testSecondaryEnvVar() {
    set_jdbc_url "postgres://foo:bar@ec2-0-0-0-0:5432/abc123" "HEROKU_POSTGRESQL_RED_JDBC"
    assertEquals "Wrong secondary DB URL" \
                 "jdbc:postgresql://ec2-0-0-0-0:5432/abc123?user=foo&password=bar&sslmode=require" \
                 "$HEROKU_POSTGRESQL_RED_JDBC_URL"
    unset HEROKU_POSTGRESQL_RED_JDBC_URL
}

testMySqlEnvVar() {
    set_jdbc_url "mysql://foo:bar@ec2-0-0-0-0:5432/abc123?reconnect=true"
    assertEquals "Wrong MySQL URL" \
                 "jdbc:mysql://ec2-0-0-0-0:5432/abc123?reconnect=true&user=foo&password=bar" \
                 "$JDBC_DATABASE_URL"
    unset JDBC_DATABASE_URL
}

testInDynoPostgres() {
    export CI="true"
    set_jdbc_url "postgres://foo:bar@ec2-0-0-0-0:5432/abc123"
    assertEquals "Wrong JDBC_DATABASE_URL" \
                 "jdbc:postgresql://ec2-0-0-0-0:5432/abc123?user=foo&password=bar" \
                 "$JDBC_DATABASE_URL"
    unset JDBC_DATABASE_URL
    unset CI
}<commit_msg>Fix tests to work on CI when they are testing that they are not on CI<commit_after>#!/usr/bin/env bash

. ${BUILDPACK_TEST_RUNNER_HOME}/lib/test_utils.sh
. ${BUILDPACK_HOME}/opt/jdbc.sh

testDefaultEnvVar() {
    local old_ci="$CI"
    unset CI
    set_jdbc_url "postgres://foo:bar@ec2-0-0-0-0:5432/abc123"
    assertEquals "Wrong JDBC_DATABASE_URL" \
                 "jdbc:postgresql://ec2-0-0-0-0:5432/abc123?user=foo&password=bar&sslmode=require" \
                 "$JDBC_DATABASE_URL"
    unset JDBC_DATABASE_URL
    export CI="$old_ci"
}

testSecondaryEnvVar() {
    local old_ci="$CI"
    unset CI
    set_jdbc_url "postgres://foo:bar@ec2-0-0-0-0:5432/abc123" "HEROKU_POSTGRESQL_RED_JDBC"
    assertEquals "Wrong secondary DB URL" \
                 "jdbc:postgresql://ec2-0-0-0-0:5432/abc123?user=foo&password=bar&sslmode=require" \
                 "$HEROKU_POSTGRESQL_RED_JDBC_URL"
    unset HEROKU_POSTGRESQL_RED_JDBC_URL
    export CI="$old_ci"
}

testMySqlEnvVar() {
    local old_ci="$CI"
    unset CI
    set_jdbc_url "mysql://foo:bar@ec2-0-0-0-0:5432/abc123?reconnect=true"
    assertEquals "Wrong MySQL URL" \
                 "jdbc:mysql://ec2-0-0-0-0:5432/abc123?reconnect=true&user=foo&password=bar" \
                 "$JDBC_DATABASE_URL"
    unset JDBC_DATABASE_URL
    export CI="$old_ci"
}

testInDynoPostgres() {
    export CI="true"
    set_jdbc_url "postgres://foo:bar@ec2-0-0-0-0:5432/abc123"
    assertEquals "Wrong JDBC_DATABASE_URL" \
                 "jdbc:postgresql://ec2-0-0-0-0:5432/abc123?user=foo&password=<PASSWORD>" \
                 "$JDBC_DATABASE_URL"
    unset JDBC_DATABASE_URL
    unset CI
}
{'fraction_non_alphanumeric': 0.1370675453047776, 'fraction_numerical': 0.06326194398682043, 'mean_word_length': 3.0372340425531914, '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': '6155101', 'n_tokens_mistral': 1346, 'n_tokens_neox': 1239, 'n_words': 137}