Skip to content

Commit

Permalink
postgrest: fix ENV["CI"] usage.
Browse files Browse the repository at this point in the history
Part of #70493.
  • Loading branch information
MikeMcQuaid committed Feb 8, 2021
1 parent c198b83 commit b8a3bd2
Showing 1 changed file with 0 additions and 40 deletions.
40 changes: 0 additions & 40 deletions Formula/postgrest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,4 @@ def install
system "cabal", "v2-update"
system "cabal", "v2-install", *std_cabal_v2_args
end

test do
return if ENV["CI"]

pg_bin = Formula["postgresql"].bin
pg_port = free_port
pg_user = "postgrest_test_user"
test_db = "test_postgrest_formula"

system "#{pg_bin}/initdb", "-D", testpath/test_db,
"--auth=trust", "--username=#{pg_user}"

system "#{pg_bin}/pg_ctl", "-D", testpath/test_db, "-l",
testpath/"#{test_db}.log", "-w", "-o", %Q("-p #{pg_port}"), "start"

begin
port = free_port
system "#{pg_bin}/createdb", "-w", "-p", pg_port, "-U", pg_user, test_db
(testpath/"postgrest.config").write <<~EOS
db-uri = "postgres://#{pg_user}@localhost:#{pg_port}/#{test_db}"
db-schema = "public"
db-anon-role = "#{pg_user}"
server-port = #{port}
EOS
pid = fork do
exec "#{bin}/postgrest", "postgrest.config"
end
sleep 5 # Wait for the server to start

output = shell_output("curl -s http://localhost:#{port}")
assert_match "200", output
ensure
begin
Process.kill("TERM", pid) if pid
ensure
system "#{pg_bin}/pg_ctl", "-D", testpath/test_db, "stop",
"-s", "-m", "fast"
end
end
end
end

0 comments on commit b8a3bd2

Please sign in to comment.