Skip to content

Commit

Permalink
introduction of P3-Tests package, renamed test classes, improved some…
Browse files Browse the repository at this point in the history
… comments
  • Loading branch information
Sven Van Caekenberghe committed Dec 31, 2018
1 parent c09e9d4 commit 448bba0
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 57 deletions.
4 changes: 3 additions & 1 deletion BaselineOfP3/BaselineOfP3.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ BaselineOfP3 >> baselineOf: spec [
spec baseline: 'ZTimestamp' with: [ spec repository: 'github://svenvc/ztimestamp:master/repository' ].
spec baseline: 'Glorp' with: [ spec repository: 'github://pharo-rdbms/glorp:master/'].
spec package: 'P3' with: [ spec requires: #('NeoJSON' 'ZTimestamp') ].
spec package: 'P3-Tests' with: [ spec requires: #('P3') ].
spec package: 'P3-Glorp' with: [ spec requires: #('P3' 'Glorp') ].
spec group: 'default' with: #('P3').
spec group: 'default' with: #('P3' 'P3-Tests').
spec group: 'core' with: #('P3').
spec group: 'glorp' with: #('P3-Glorp') ]
]
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"
P3ArrayValueParserTests holds unit tests for P3ArrayValueParser.
P3ArrayValueParserTest holds unit tests for P3ArrayValueParser.
"
Class {
#name : #P3ArrayValueParserTests,
#name : #P3ArrayValueParserTest,
#superclass : #TestCase,
#category : #P3
#category : #'P3-Tests'
}

{ #category : #tests }
P3ArrayValueParserTests >> testIntegers [
P3ArrayValueParserTest >> testIntegers [
self
assert: (P3ArrayValueParser new
on: '{{1,2},{3,4},{0,-1}}' readStream;
Expand All @@ -18,7 +18,7 @@ P3ArrayValueParserTests >> testIntegers [
]

{ #category : #tests }
P3ArrayValueParserTests >> testPlain [
P3ArrayValueParserTest >> testPlain [
self
assert: (P3ArrayValueParser new
on: '{{one,two},{three,four},{NULL,""}' readStream;
Expand All @@ -27,7 +27,7 @@ P3ArrayValueParserTests >> testPlain [
]

{ #category : #tests }
P3ArrayValueParserTests >> testSpecial [
P3ArrayValueParserTest >> testSpecial [
self
assert: (P3ArrayValueParser new
on: '{{one,two},{"\"","\\"},{NULL,""},{"NULL",1}' readStream;
Expand Down
66 changes: 33 additions & 33 deletions P3/P3ClientTests.class.st → P3-Tests/P3ClientTest.class.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"
P3ClientTests holds unit tests for the P3 PSQL client.
P3ClientTest holds unit tests for the P3 PSQL client.
Configure by setting my class side's connection URL.
Expand All @@ -17,19 +17,19 @@ Benchmarks
P3ClientTests new runAllTests.
"
Class {
#name : #P3ClientTests,
#name : #P3ClientTest,
#superclass : #TestCase,
#instVars : [
'client'
],
#classVars : [
'Url'
],
#category : #P3
#category : #'P3-Tests'
}

{ #category : #accessing }
P3ClientTests class >> url [
P3ClientTest class >> url [
"Return the default connection URL to use for P3 clients in the unit tests.
Note that the default here corresponds to the default on Travis CI's postgresql service,
user postgres with a blank password on localhost.
Expand All @@ -39,7 +39,7 @@ P3ClientTests class >> url [
]

{ #category : #accessing }
P3ClientTests class >> url: stringOrUrl [
P3ClientTest class >> url: stringOrUrl [
"Set the connection URL to be used for P3 Clients in the unit tests.
The general syntax is psql://sven:secret@localhost:5432/database
The minimal form is psql://user@localhost (a user, blank password, localhost)"
Expand All @@ -48,12 +48,12 @@ P3ClientTests class >> url: stringOrUrl [
]

{ #category : #benchmarking }
P3ClientTests >> benchmark1Size [
P3ClientTest >> benchmark1Size [
^ 10000
]

{ #category : #benchmarking }
P3ClientTests >> runAllTests [
P3ClientTest >> runAllTests [
"Runs all tests on the same connection/session"

| testSelectors timeToRun |
Expand All @@ -65,7 +65,7 @@ P3ClientTests >> runAllTests [
]

{ #category : #benchmarking }
P3ClientTests >> runBenchmark1 [
P3ClientTest >> runBenchmark1 [
| result timeToRun |
result := nil.
self setUp.
Expand All @@ -76,7 +76,7 @@ P3ClientTests >> runBenchmark1 [
]

{ #category : #benchmarking }
P3ClientTests >> runBenchmark1Bench [
P3ClientTest >> runBenchmark1Bench [
| result timeToRun |
result := nil.
self setUp.
Expand All @@ -87,15 +87,15 @@ P3ClientTests >> runBenchmark1Bench [
]

{ #category : #running }
P3ClientTests >> setUp [
P3ClientTest >> setUp [
super setUp.
client := P3Client new.
client url: self class url.
client connect
]

{ #category : #benchmarking }
P3ClientTests >> setupBenchmark1 [
P3ClientTest >> setupBenchmark1 [
| timeToRun |
self setUp.
timeToRun := [
Expand All @@ -111,7 +111,7 @@ P3ClientTests >> setupBenchmark1 [
]

{ #category : #versionInfo }
P3ClientTests >> supportsJsonB [
P3ClientTest >> supportsJsonB [

| record version |

Expand All @@ -124,13 +124,13 @@ P3ClientTests >> supportsJsonB [
]

{ #category : #running }
P3ClientTests >> tearDown [
P3ClientTest >> tearDown [
client close.
super tearDown
]

{ #category : #testing }
P3ClientTests >> testArrayTypes [
P3ClientTest >> testArrayTypes [
| result |
client execute: 'DROP TABLE IF EXISTS table_a'.
client execute: 'CREATE TABLE table_a (id INTEGER, name TEXT, text_a TEXT[], int_a INTEGER[])'.
Expand All @@ -150,14 +150,14 @@ P3ClientTests >> testArrayTypes [
]

{ #category : #testing }
P3ClientTests >> testBooleanConversion [
P3ClientTest >> testBooleanConversion [
| result |
result := client query: 'SELECT b::boolean FROM (VALUES (true), (false), (NULL)) t(b)'.
self assert: result data equals: #((true) (false) (nil))
]

{ #category : #testing }
P3ClientTests >> testChronology [
P3ClientTest >> testChronology [
| result |
client execute: 'DROP TABLE IF EXISTS table1'.
client execute: 'CREATE TABLE table1 (id SERIAL PRIMARY KEY, name TEXT, timestamp_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP, date_created DATE DEFAULT CURRENT_DATE, time_created TIME DEFAULT CURRENT_TIME)'.
Expand All @@ -180,13 +180,13 @@ P3ClientTests >> testChronology [
]

{ #category : #testing }
P3ClientTests >> testConnection [
P3ClientTest >> testConnection [
self assert: client isConnected.
self assert: client isWorking.
]

{ #category : #testing }
P3ClientTests >> testEmptyString [
P3ClientTest >> testEmptyString [
| result |
client execute: 'DROP TABLE IF EXISTS table1'.
client execute: 'CREATE TABLE table1 (id INTEGER, string VARCHAR)'.
Expand All @@ -200,7 +200,7 @@ P3ClientTests >> testEmptyString [
]

{ #category : #testing }
P3ClientTests >> testEnum [
P3ClientTest >> testEnum [

| result ooid |

Expand All @@ -227,19 +227,19 @@ P3ClientTests >> testEnum [
]

{ #category : #testing }
P3ClientTests >> testError [
P3ClientTest >> testError [
self should: [ client query: 'SELECT * FROM abcdef' ] raise: P3Error
]

{ #category : #testing }
P3ClientTests >> testIntegerConversion [
P3ClientTest >> testIntegerConversion [
| result |
result := client query: 'SELECT i::integer FROM (VALUES (-1), (1), (NULL), (1234567890)) t(i)'.
self assert: result data equals: #((-1) (1) (nil) (1234567890))
]

{ #category : #testing }
P3ClientTests >> testJsonConversion [
P3ClientTest >> testJsonConversion [
| data result |

self supportsJsonB ifFalse: [ ^ self skip ].
Expand All @@ -256,7 +256,7 @@ P3ClientTests >> testJsonConversion [
]

{ #category : #testing }
P3ClientTests >> testMultiStatement [
P3ClientTest >> testMultiStatement [
| result |
client execute: 'DROP TABLE IF EXISTS table1'.
client execute: 'CREATE TABLE table1 (id INTEGER, name TEXT, enabled BOOLEAN)'.
Expand All @@ -272,7 +272,7 @@ P3ClientTests >> testMultiStatement [
]

{ #category : #testing }
P3ClientTests >> testNonAsciiStrings [
P3ClientTest >> testNonAsciiStrings [
| result |
client execute: 'DROP TABLE IF EXISTS table1'.
client execute: 'CREATE TABLE table1 (id INTEGER, string VARCHAR)'.
Expand All @@ -286,7 +286,7 @@ P3ClientTests >> testNonAsciiStrings [
]

{ #category : #testing }
P3ClientTests >> testNotification [
P3ClientTest >> testNotification [
| raised |
raised := false.
[ client query: 'SET client_min_messages TO notice; DROP TABLE IF EXISTS abcdef' ]
Expand All @@ -301,7 +301,7 @@ P3ClientTests >> testNotification [
]

{ #category : #testing }
P3ClientTests >> testQueryCatalog [
P3ClientTest >> testQueryCatalog [
| result |
result := client query: 'SELECT schemaname,tablename FROM pg_catalog.pg_tables'.
"there are two columns"
Expand All @@ -315,7 +315,7 @@ P3ClientTests >> testQueryCatalog [
]

{ #category : #testing }
P3ClientTests >> testSession [
P3ClientTest >> testSession [

| session |

Expand Down Expand Up @@ -351,7 +351,7 @@ P3ClientTests >> testSession [
]

{ #category : #testing }
P3ClientTests >> testSimpleTable [
P3ClientTest >> testSimpleTable [
| result |
client execute: 'DROP TABLE IF EXISTS table1'.
client execute: 'CREATE TABLE table1 (id INTEGER, name TEXT, enabled BOOLEAN)'.
Expand All @@ -372,7 +372,7 @@ P3ClientTests >> testSimpleTable [
]

{ #category : #testing }
P3ClientTests >> testSqlFunction [
P3ClientTest >> testSqlFunction [
| x y result |
client execute: 'DROP FUNCTION IF EXISTS my_add(x INTEGER, y INTEGER)'.
client execute: 'CREATE FUNCTION my_add(x INTEGER, y INTEGER) RETURNS INTEGER AS $$ SELECT x + y $$ LANGUAGE SQL'.
Expand All @@ -384,7 +384,7 @@ P3ClientTests >> testSqlFunction [
]

{ #category : #testing }
P3ClientTests >> testStringEscaping [
P3ClientTest >> testStringEscaping [
| result string |
client execute: 'DROP TABLE IF EXISTS table1'.
client execute: 'CREATE TABLE table1 (id INTEGER, string VARCHAR)'.
Expand All @@ -397,7 +397,7 @@ P3ClientTests >> testStringEscaping [
]

{ #category : #testing }
P3ClientTests >> testTimeout [
P3ClientTest >> testTimeout [
"Reconnect with an explicit timeout"
client close.
client url: Url.
Expand All @@ -410,7 +410,7 @@ P3ClientTests >> testTimeout [
]

{ #category : #testing }
P3ClientTests >> testTimezone [
P3ClientTest >> testTimezone [
| result originalTimezone |
client execute: 'DROP TABLE IF EXISTS table1'.
client execute: 'CREATE TABLE table1 (id SERIAL PRIMARY KEY, name TEXT, t1 TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP, t2 TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP)'.
Expand Down Expand Up @@ -441,7 +441,7 @@ P3ClientTests >> testTimezone [
]

{ #category : #testing }
P3ClientTests >> testUuid [
P3ClientTest >> testUuid [

| result uuid num |

Expand Down
Loading

0 comments on commit 448bba0

Please sign in to comment.