-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
140 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/composer.lock | ||
/vendor | ||
/docker/database |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
version: '3.7' | ||
|
||
services: | ||
pgasync-postgres: | ||
image: postgres:11 | ||
environment: | ||
- PGDATA=/database | ||
- POSTGRES_PASSWORD=some_password | ||
- TZ=America/New_York | ||
volumes: | ||
- .:/app | ||
- ./database:/database | ||
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d | ||
ports: | ||
- "5432:5432" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
echo "Running as $USER in $PWD" | ||
|
||
createuser -U postgres --createdb pgasync | ||
createuser -U postgres --createdb pgasyncpw | ||
psql -U postgres -c "ALTER ROLE pgasyncpw PASSWORD 'example_password'" | ||
|
||
cd /app | ||
cp pg_hba_new.conf database/pg_hba.conf | ||
|
||
createdb -U pgasync pgasync_test | ||
|
||
psql -U pgasync -f test_db.sql pgasync_test | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# TYPE DATABASE USER ADDRESS METHOD | ||
|
||
# "local" is for Unix domain socket connections only | ||
local all all trust | ||
# IPv4 local connections: | ||
host all all 127.0.0.1/32 trust | ||
# IPv6 local connections: | ||
host all all ::1/128 trust | ||
# Allow replication connections from localhost, by a user with the | ||
# replication privilege. | ||
local replication all trust | ||
host replication all 127.0.0.1/32 trust | ||
host replication all ::1/128 trust | ||
|
||
host all pgasync all trust | ||
host all all all md5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
CREATE TABLE thing ( | ||
id SERIAL, | ||
thing_type varchar(50), | ||
thing_description TEXT, | ||
thing_cost decimal(10,4), | ||
thing_in_stock bool | ||
); | ||
|
||
INSERT INTO thing(thing_type, thing_description, thing_cost, thing_in_stock) | ||
VALUES('pen', NULL, 50.23, 'f'); | ||
INSERT INTO thing(thing_type, thing_description, thing_cost, thing_in_stock) | ||
VALUES('pencil', 'something you write with', 27.50, null); | ||
INSERT INTO thing(thing_type, thing_description, thing_cost, thing_in_stock) | ||
VALUES('marker', NULL, 50.23, 't'); | ||
|
||
CREATE TABLE test_bool_param ( | ||
id serial not null, | ||
b boolean, | ||
primary key(id) | ||
); | ||
insert into test_bool_param(b) values(true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
echo "Waiting for database..." | ||
|
||
ROW_COUNT=0 | ||
|
||
TRY_COUNT=0 | ||
|
||
while [ "$ROW_COUNT" -ne 1 ]; do | ||
if [ "$TRY_COUNT" -ge 60 ]; then | ||
echo "Timeout waiting for database..." | ||
exit 1; | ||
fi | ||
sleep 5 | ||
TRY_COUNT=$(($TRY_COUNT+1)) | ||
echo "Attempt $TRY_COUNT..." | ||
if ! ROW_COUNT=$(docker exec docker_pgasync-postgres_1 psql -U postgres pgasync_test -c "select count(*) from test_bool_param" -A -t); then | ||
ROW_COUNT=0 | ||
fi | ||
done | ||
|
||
echo "Database is up..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace PgAsync\Tests\Integration; | ||
|
||
use PgAsync\Client; | ||
use Rx\Observer\CallbackObserver; | ||
|
||
class Md5PasswordTest extends TestCase | ||
{ | ||
public function testMd5Login() | ||
{ | ||
$client = new Client([ | ||
"user" => "pgasyncpw", | ||
"database" => $this->getDbName(), | ||
"auto_disconnect" => true, | ||
"password" => "example_password" | ||
], $this->getLoop()); | ||
|
||
$hello = null; | ||
|
||
$client->query("SELECT 'Hello' AS hello") | ||
->subscribe(new CallbackObserver( | ||
function ($x) use (&$hello) { | ||
$this->assertNull($hello); | ||
$hello = $x['hello']; | ||
}, | ||
function ($e) { | ||
$this->fail('Unexpected error'); | ||
}, | ||
function () { | ||
$this->getLoop()->addTimer(0.1, function () { | ||
$this->stopLoop(); | ||
}); | ||
} | ||
)); | ||
|
||
$this->runLoopWithTimeout(2); | ||
|
||
$this->assertEquals('Hello', $hello); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters