Adjust test, so that it runs on Windows

This commit is contained in:
Lars Kanis 2011-07-14 11:08:17 +02:00
parent 6d6b94f87e
commit c36abdd906
2 changed files with 17 additions and 10 deletions

View File

@ -16,9 +16,9 @@ ldap_groups:
pg_connection:
dbname: postgres
host: localhost
port: 54321
# needed for postgres-pr:
# host: localhost
# port: 54321
# user: insert_your_username_here
# password:

View File

@ -41,9 +41,9 @@ class TestPgLdapSync < Test::Unit::TestCase
@port = 54321
ENV['PGPORT'] = @port.to_s
ENV['PGHOST'] = 'localhost'
unless File.exist?('temp/pg_data')
unless File.exist?('temp/pg_data/PG_VERSION')
FileUtils.mkdir_p 'temp/pg_data'
log_and_run 'initdb', '-D', 'temp/pg_data'
log_and_run 'initdb', '-D', 'temp/pg_data', '--no-locale'
end
log_and_run 'pg_ctl', '-w', '-o', "-k.", '-D', 'temp/pg_data', 'start'
log_and_run 'psql', '-e', '-c', "DROP ROLE IF EXISTS fred, wilma, \"Flintstones\", \"Wilmas\", \"All Users\"", 'postgres'
@ -67,12 +67,21 @@ class TestPgLdapSync < Test::Unit::TestCase
/^\s*#{args[0]}[ |]*#{args[1]}[ |\{"]*#{args[2..-1].join('[", ]+')}["\}\s]*$/
end
def exec_psql_du
text = if RUBY_PLATFORM=~/mingw|mswin/
`psql -c \\du postgres`
else
`psql -c \\\\du postgres`
end
puts text
return text
end
def test_sanity
PgLdapSync::Application.run(%w[-c test/fixtures/config-ldapdb.yaml -vv])
ENV['LC_MESSAGES'] = 'C'
psql_du = `psql -c \\\\du postgres`
puts psql_du
psql_du = exec_psql_du
assert_match(psqlre('All Users','Cannot login'), psql_du)
assert_match(psqlre('Flintstones','Cannot login'), psql_du)
@ -84,8 +93,7 @@ class TestPgLdapSync < Test::Unit::TestCase
@directory['cn=Flintstones,dc=example,dc=com']['member'].pop
PgLdapSync::Application.run(%w[-c test/fixtures/config-ldapdb.yaml -vv])
psql_du = `psql -c \\\\du postgres`
puts psql_du
psql_du = exec_psql_du
assert_match(psqlre('All Users','Cannot login'), psql_du)
assert_match(psqlre('Flintstones','Cannot login'), psql_du)
@ -99,8 +107,7 @@ class TestPgLdapSync < Test::Unit::TestCase
@directory['cn=Flintstones,dc=example,dc=com']['member'] << 'cn=Wilma Flintstone,dc=example,dc=com'
PgLdapSync::Application.run(%w[-c test/fixtures/config-ldapdb.yaml -vv])
psql_du = `psql -c \\\\du postgres`
puts psql_du
psql_du = exec_psql_du
assert_match(psqlre('All Users','Cannot login'), psql_du)
assert_match(psqlre('Flintstones','Cannot login'), psql_du)