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: pg_connection:
dbname: postgres dbname: postgres
host: localhost
port: 54321
# needed for postgres-pr: # needed for postgres-pr:
# host: localhost
# port: 54321
# user: insert_your_username_here # user: insert_your_username_here
# password: # password:

View File

@ -41,9 +41,9 @@ class TestPgLdapSync < Test::Unit::TestCase
@port = 54321 @port = 54321
ENV['PGPORT'] = @port.to_s ENV['PGPORT'] = @port.to_s
ENV['PGHOST'] = 'localhost' ENV['PGHOST'] = 'localhost'
unless File.exist?('temp/pg_data') unless File.exist?('temp/pg_data/PG_VERSION')
FileUtils.mkdir_p 'temp/pg_data' 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 end
log_and_run 'pg_ctl', '-w', '-o', "-k.", '-D', 'temp/pg_data', 'start' 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' 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]*$/ /^\s*#{args[0]}[ |]*#{args[1]}[ |\{"]*#{args[2..-1].join('[", ]+')}["\}\s]*$/
end 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 def test_sanity
PgLdapSync::Application.run(%w[-c test/fixtures/config-ldapdb.yaml -vv]) PgLdapSync::Application.run(%w[-c test/fixtures/config-ldapdb.yaml -vv])
ENV['LC_MESSAGES'] = 'C' ENV['LC_MESSAGES'] = 'C'
psql_du = `psql -c \\\\du postgres` psql_du = exec_psql_du
puts psql_du
assert_match(psqlre('All Users','Cannot login'), psql_du) assert_match(psqlre('All Users','Cannot login'), psql_du)
assert_match(psqlre('Flintstones','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 @directory['cn=Flintstones,dc=example,dc=com']['member'].pop
PgLdapSync::Application.run(%w[-c test/fixtures/config-ldapdb.yaml -vv]) PgLdapSync::Application.run(%w[-c test/fixtures/config-ldapdb.yaml -vv])
psql_du = `psql -c \\\\du postgres` psql_du = exec_psql_du
puts psql_du
assert_match(psqlre('All Users','Cannot login'), psql_du) assert_match(psqlre('All Users','Cannot login'), psql_du)
assert_match(psqlre('Flintstones','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' @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]) PgLdapSync::Application.run(%w[-c test/fixtures/config-ldapdb.yaml -vv])
psql_du = `psql -c \\\\du postgres` psql_du = exec_psql_du
puts psql_du
assert_match(psqlre('All Users','Cannot login'), psql_du) assert_match(psqlre('All Users','Cannot login'), psql_du)
assert_match(psqlre('Flintstones','Cannot login'), psql_du) assert_match(psqlre('Flintstones','Cannot login'), psql_du)