Skip to content

Commit d1aa99b

Browse files
author
Daniel Cesario
committed
Introducing PG connection test and dependency
1 parent 863f52f commit d1aa99b

8 files changed

+320
-3
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ Dockerfile
33
docker-compose.yml
44
Makefile
55
README.md
6+
oauth.sh
7+
spec/*
68
local/*
79
pgdata/*

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RUN groupadd -r xman -g 1001 \
1111
&& useradd -u 1001 -r -g xman -d /opt/project-x/ -s /sbin/nologin -c "Docker image user" xman \
1212
&& chown -R xman:xman /opt/project-x/
1313

14-
RUN carton install --deployment
14+
RUN carton install
1515

1616
#Setting the PostgreSQL Host
1717
ENV PG_HOST=postgresql

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ kill: ## Kill the compose in the local machine.
4343
docker-compose stop
4444

4545
bash: ## Start bash in the build IMAGE_NAME.
46-
docker run --rm --entrypoint=/bin/bash -it $(LOCAL_IMAGE)
46+
docker-compose run --rm --entrypoint=/bin/bash mojo
4747

4848
tag: ## Tag IMAGE_NAME
4949
docker tag $(LOCAL_IMAGE) $(REMOTE_IMAGE)

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Our cool project. We use #proejectx on barcelonapm slack
44

55
# Swagger spec (WIP)
66

7-
To render/edit the Swagger spec got to the [Swagger Editor](http://editor.swagger.io/#!/)
7+
To render/edit the Swagger spec go to the [Swagger Editor](http://editor.swagger.io/#!/)
88
* we use #proejectx on barcelonapm slack.
99
* Dockerhub Namespace: barcelonapm
1010

cpanfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
requires 'Mojolicious';
22
requires 'Mojolicious::Plugin::OAuth2';
33
requires 'IO::Socket::SSL';
4+
requires 'DBD::Pg';
5+
requires 'Mojo::Pg';

cpanfile.snapshot

+293
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,147 @@
11
# carton snapshot format: version 1.0
22
DISTRIBUTIONS
3+
Class-Method-Modifiers-2.12
4+
pathname: E/ET/ETHER/Class-Method-Modifiers-2.12.tar.gz
5+
provides:
6+
Class::Method::Modifiers 2.12
7+
requirements:
8+
B 0
9+
Carp 0
10+
Exporter 0
11+
ExtUtils::MakeMaker 0
12+
base 0
13+
perl 5.006
14+
strict 0
15+
warnings 0
16+
Clone-0.39
17+
pathname: G/GA/GARU/Clone-0.39.tar.gz
18+
provides:
19+
Clone 0.39
20+
requirements:
21+
ExtUtils::MakeMaker 0
22+
Test::More 0
23+
DBD-Pg-3.5.3
24+
pathname: T/TU/TURNSTEP/DBD-Pg-3.5.3.tar.gz
25+
provides:
26+
Bundle::DBD::Pg v3.5.3
27+
DBD::Pg v3.5.3
28+
requirements:
29+
DBI 1.614
30+
ExtUtils::MakeMaker 6.11
31+
Test::More 0.88
32+
Time::HiRes 0
33+
version 0
34+
DBI-1.636
35+
pathname: T/TI/TIMB/DBI-1.636.tar.gz
36+
provides:
37+
Bundle::DBI 12.008696
38+
DBD::DBM 0.08
39+
DBD::DBM::Statement 0.08
40+
DBD::DBM::Table 0.08
41+
DBD::DBM::db 0.08
42+
DBD::DBM::dr 0.08
43+
DBD::DBM::st 0.08
44+
DBD::ExampleP 12.014311
45+
DBD::ExampleP::db 12.014311
46+
DBD::ExampleP::dr 12.014311
47+
DBD::ExampleP::st 12.014311
48+
DBD::File 0.44
49+
DBD::File::DataSource::File 0.44
50+
DBD::File::DataSource::Stream 0.44
51+
DBD::File::Statement 0.44
52+
DBD::File::Table 0.44
53+
DBD::File::TableSource::FileSystem 0.44
54+
DBD::File::db 0.44
55+
DBD::File::dr 0.44
56+
DBD::File::st 0.44
57+
DBD::Gofer 0.015327
58+
DBD::Gofer::Policy::Base 0.010088
59+
DBD::Gofer::Policy::classic 0.010088
60+
DBD::Gofer::Policy::pedantic 0.010088
61+
DBD::Gofer::Policy::rush 0.010088
62+
DBD::Gofer::Transport::Base 0.014121
63+
DBD::Gofer::Transport::corostream undef
64+
DBD::Gofer::Transport::null 0.010088
65+
DBD::Gofer::Transport::pipeone 0.010088
66+
DBD::Gofer::Transport::stream 0.014599
67+
DBD::Gofer::db 0.015327
68+
DBD::Gofer::dr 0.015327
69+
DBD::Gofer::st 0.015327
70+
DBD::NullP 12.014715
71+
DBD::NullP::db 12.014715
72+
DBD::NullP::dr 12.014715
73+
DBD::NullP::st 12.014715
74+
DBD::Proxy 0.2004
75+
DBD::Proxy::RPC::PlClient 0.2004
76+
DBD::Proxy::db 0.2004
77+
DBD::Proxy::dr 0.2004
78+
DBD::Proxy::st 0.2004
79+
DBD::Sponge 12.010003
80+
DBD::Sponge::db 12.010003
81+
DBD::Sponge::dr 12.010003
82+
DBD::Sponge::st 12.010003
83+
DBDI 12.015129
84+
DBI 1.636
85+
DBI::Const::GetInfo::ANSI 2.008697
86+
DBI::Const::GetInfo::ODBC 2.011374
87+
DBI::Const::GetInfoReturn 2.008697
88+
DBI::Const::GetInfoType 2.008697
89+
DBI::DBD 12.015129
90+
DBI::DBD::Metadata 2.014214
91+
DBI::DBD::SqlEngine 0.06
92+
DBI::DBD::SqlEngine::DataSource 0.06
93+
DBI::DBD::SqlEngine::Statement 0.06
94+
DBI::DBD::SqlEngine::Table 0.06
95+
DBI::DBD::SqlEngine::TableSource 0.06
96+
DBI::DBD::SqlEngine::TieMeta 0.06
97+
DBI::DBD::SqlEngine::TieTables 0.06
98+
DBI::DBD::SqlEngine::db 0.06
99+
DBI::DBD::SqlEngine::dr 0.06
100+
DBI::DBD::SqlEngine::st 0.06
101+
DBI::Gofer::Execute 0.014283
102+
DBI::Gofer::Request 0.012537
103+
DBI::Gofer::Response 0.011566
104+
DBI::Gofer::Serializer::Base 0.009950
105+
DBI::Gofer::Serializer::DataDumper 0.009950
106+
DBI::Gofer::Serializer::Storable 0.015586
107+
DBI::Gofer::Transport::Base 0.012537
108+
DBI::Gofer::Transport::pipeone 0.012537
109+
DBI::Gofer::Transport::stream 0.012537
110+
DBI::Profile 2.015065
111+
DBI::ProfileData 2.010008
112+
DBI::ProfileDumper 2.015325
113+
DBI::ProfileDumper::Apache 2.014121
114+
DBI::ProfileSubs 0.009396
115+
DBI::ProxyServer 0.3005
116+
DBI::ProxyServer::db 0.3005
117+
DBI::ProxyServer::dr 0.3005
118+
DBI::ProxyServer::st 0.3005
119+
DBI::SQL::Nano 1.015544
120+
DBI::SQL::Nano::Statement_ 1.015544
121+
DBI::SQL::Nano::Table_ 1.015544
122+
DBI::Util::CacheMemory 0.010315
123+
DBI::Util::_accessor 0.009479
124+
DBI::common 1.636
125+
requirements:
126+
ExtUtils::MakeMaker 6.48
127+
Test::Simple 0.90
128+
perl 5.008
129+
Devel-GlobalDestruction-0.14
130+
pathname: H/HA/HAARG/Devel-GlobalDestruction-0.14.tar.gz
131+
provides:
132+
Devel::GlobalDestruction 0.14
133+
requirements:
134+
ExtUtils::MakeMaker 0
135+
Sub::Exporter::Progressive 0.001011
136+
perl 5.006
137+
Hash-Merge-0.200
138+
pathname: R/RE/REHSACK/Hash-Merge-0.200.tar.gz
139+
provides:
140+
Hash::Merge 0.200
141+
requirements:
142+
Clone 0
143+
ExtUtils::MakeMaker 0
144+
perl 5.008001
3145
IO-Socket-SSL-2.047
4146
pathname: S/SU/SULLR/IO-Socket-SSL-2.047.tar.gz
5147
provides:
@@ -17,6 +159,88 @@ DISTRIBUTIONS
17159
Mozilla::CA 0
18160
Net::SSLeay 1.46
19161
Scalar::Util 0
162+
MRO-Compat-0.13
163+
pathname: H/HA/HAARG/MRO-Compat-0.13.tar.gz
164+
provides:
165+
MRO::Compat 0.13
166+
requirements:
167+
ExtUtils::MakeMaker 0
168+
perl 5.006
169+
Module-Build-0.4222
170+
pathname: L/LE/LEONT/Module-Build-0.4222.tar.gz
171+
provides:
172+
Module::Build 0.4222
173+
Module::Build::Base 0.4222
174+
Module::Build::Compat 0.4222
175+
Module::Build::Config 0.4222
176+
Module::Build::Cookbook 0.4222
177+
Module::Build::Dumper 0.4222
178+
Module::Build::Notes 0.4222
179+
Module::Build::PPMMaker 0.4222
180+
Module::Build::Platform::Default 0.4222
181+
Module::Build::Platform::MacOS 0.4222
182+
Module::Build::Platform::Unix 0.4222
183+
Module::Build::Platform::VMS 0.4222
184+
Module::Build::Platform::VOS 0.4222
185+
Module::Build::Platform::Windows 0.4222
186+
Module::Build::Platform::aix 0.4222
187+
Module::Build::Platform::cygwin 0.4222
188+
Module::Build::Platform::darwin 0.4222
189+
Module::Build::Platform::os2 0.4222
190+
Module::Build::PodParser 0.4222
191+
requirements:
192+
CPAN::Meta 2.142060
193+
CPAN::Meta::YAML 0.003
194+
Cwd 0
195+
Data::Dumper 0
196+
ExtUtils::CBuilder 0.27
197+
ExtUtils::Install 0
198+
ExtUtils::Manifest 0
199+
ExtUtils::Mkbootstrap 0
200+
ExtUtils::ParseXS 2.21
201+
File::Basename 0
202+
File::Compare 0
203+
File::Copy 0
204+
File::Find 0
205+
File::Path 0
206+
File::Spec 0.82
207+
File::Temp 0.15
208+
Getopt::Long 0
209+
Module::Metadata 1.000002
210+
Parse::CPAN::Meta 1.4401
211+
Perl::OSType 1
212+
Pod::Man 2.17
213+
TAP::Harness 3.29
214+
Test::More 0.49
215+
Text::Abbrev 0
216+
Text::ParseWords 0
217+
perl 5.006001
218+
version 0.87
219+
Module-Runtime-0.014
220+
pathname: Z/ZE/ZEFRAM/Module-Runtime-0.014.tar.gz
221+
provides:
222+
Module::Runtime 0.014
223+
requirements:
224+
Module::Build 0
225+
Test::More 0
226+
perl 5.006
227+
strict 0
228+
warnings 0
229+
Mojo-Pg-3.05
230+
pathname: S/SR/SRI/Mojo-Pg-3.05.tar.gz
231+
provides:
232+
Mojo::Pg 3.05
233+
Mojo::Pg::Database undef
234+
Mojo::Pg::Migrations undef
235+
Mojo::Pg::PubSub undef
236+
Mojo::Pg::Results undef
237+
Mojo::Pg::Transaction undef
238+
requirements:
239+
DBD::Pg 3.005001
240+
ExtUtils::MakeMaker 0
241+
Mojolicious 7.15
242+
SQL::Abstract 1.81
243+
perl 5.010001
20244
Mojolicious-7.30
21245
pathname: S/SR/SRI/Mojolicious-7.30.tar.gz
22246
provides:
@@ -147,6 +371,36 @@ DISTRIBUTIONS
147371
IO::Socket::SSL 1.94
148372
Mojolicious 6.0
149373
Test::More 0.88
374+
Moo-2.003002
375+
pathname: H/HA/HAARG/Moo-2.003002.tar.gz
376+
provides:
377+
Method::Generate::Accessor undef
378+
Method::Generate::BuildAll undef
379+
Method::Generate::Constructor undef
380+
Method::Generate::DemolishAll undef
381+
Moo 2.003002
382+
Moo::HandleMoose undef
383+
Moo::HandleMoose::FakeConstructor undef
384+
Moo::HandleMoose::FakeMetaClass undef
385+
Moo::HandleMoose::_TypeMap undef
386+
Moo::Object undef
387+
Moo::Role 2.003002
388+
Moo::_Utils undef
389+
Moo::_mro undef
390+
Moo::_strictures undef
391+
Moo::sification undef
392+
oo undef
393+
requirements:
394+
Class::Method::Modifiers 1.1
395+
Devel::GlobalDestruction 0.11
396+
Exporter 5.57
397+
ExtUtils::MakeMaker 0
398+
Module::Runtime 0.014
399+
Role::Tiny 2.000004
400+
Scalar::Util 0
401+
Sub::Defer 2.003001
402+
Sub::Quote 2.003001
403+
perl 5.006
150404
Mozilla-CA-20160104
151405
pathname: A/AB/ABH/Mozilla-CA-20160104.tar.gz
152406
provides:
@@ -165,3 +419,42 @@ DISTRIBUTIONS
165419
MIME::Base64 0
166420
Test::More 0.60_01
167421
perl 5.005
422+
Role-Tiny-2.000005
423+
pathname: H/HA/HAARG/Role-Tiny-2.000005.tar.gz
424+
provides:
425+
Role::Tiny 2.000005
426+
Role::Tiny::With 2.000005
427+
requirements:
428+
Exporter 5.57
429+
perl 5.006
430+
SQL-Abstract-1.84
431+
pathname: I/IL/ILMARI/SQL-Abstract-1.84.tar.gz
432+
provides:
433+
SQL::Abstract 1.84
434+
SQL::Abstract::Test undef
435+
SQL::Abstract::Tree undef
436+
requirements:
437+
Exporter 5.57
438+
ExtUtils::MakeMaker 0
439+
Hash::Merge 0.12
440+
List::Util 0
441+
MRO::Compat 0.12
442+
Moo 2.000001
443+
Scalar::Util 0
444+
Sub::Quote 2.000001
445+
Text::Balanced 2.00
446+
Sub-Exporter-Progressive-0.001013
447+
pathname: F/FR/FREW/Sub-Exporter-Progressive-0.001013.tar.gz
448+
provides:
449+
Sub::Exporter::Progressive 0.001013
450+
requirements:
451+
ExtUtils::MakeMaker 0
452+
Sub-Quote-2.003001
453+
pathname: H/HA/HAARG/Sub-Quote-2.003001.tar.gz
454+
provides:
455+
Sub::Defer 2.003001
456+
Sub::Quote 2.003001
457+
requirements:
458+
ExtUtils::MakeMaker 0
459+
Scalar::Util 0
460+
perl 5.006

docker-compose.yml

+3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ services:
1414
- ./lib:/opt/project-x/lib
1515
- ./public:/opt/project-x/public
1616
- ./templates:/opt/project-x/templates
17+
- ./t:/opt/project-x/t
1718
postgresql:
1819
image: postgres:9.6-alpine
1920
restart: always
21+
ports:
22+
- "5432:5432"
2023
environment:
2124
- POSTGRES_PASSWORD=mysecretpassword
2225
- POSTGRES_USER=postgres

t/dbconnection.t

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use Mojo::Base -strict;
2+
3+
use Test::More;
4+
use Mojo::Pg;
5+
6+
# Minimal connection string with database
7+
my $pg = Mojo::Pg->new('postgresql://postgres:mysecretpassword@postgresql:5432/postgres');
8+
is $pg->dsn, 'dbi:Pg:dbname=postgres;host=postgresql;port=5432', 'right data source';
9+
is $pg->username, 'postgres', 'right username';
10+
is $pg->password, 'mysecretpassword', 'right password';
11+
my $options = {AutoCommit => 1, AutoInactiveDestroy => 1, PrintError => 0,
12+
RaiseError => 1};
13+
is_deeply $pg->options, $options, 'right options';
14+
15+
ok $pg->db->ping, 'connected';
16+
17+
done_testing();

0 commit comments

Comments
 (0)