Fix compilation of tests
FossilOrigin-Name: 04c3ced613448bb557d961e41ea903a5028e5dba85f782edc134b1b7286ad115
This commit is contained in:
parent
2a0c3bb8a1
commit
c2116f1808
2 changed files with 30 additions and 28 deletions
|
@ -1,8 +1,10 @@
|
||||||
|
include ../extra.mk
|
||||||
|
|
||||||
PROG_NOINST = tests
|
PROG_NOINST = tests
|
||||||
SRCS = tests.m
|
SRCS = tests.m
|
||||||
|
|
||||||
include ../buildsys.mk
|
include ../buildsys.mk
|
||||||
|
|
||||||
CPPFLAGS += -I../src -I../src/exceptions
|
CPPFLAGS += -I../src -I../src/exceptions
|
||||||
LIBS += -L../src -lobjpgsql
|
LIBS := -L../src -lobjpgsql ${OBJFW_LIBS} ${LIBS}
|
||||||
LD = ${OBJC}
|
LD = ${OBJC}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017
|
* Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017, 2018
|
||||||
* Jonathan Schleifer <js@heap.zone>
|
* Jonathan Schleifer <js@heap.zone>
|
||||||
*
|
*
|
||||||
* https://heap.zone/git/objpgsql.git
|
* https://heap.zone/git/objpgsql.git
|
||||||
|
@ -26,9 +26,9 @@
|
||||||
#import "PGConnection.h"
|
#import "PGConnection.h"
|
||||||
#import "PGConnectionFailedException.h"
|
#import "PGConnectionFailedException.h"
|
||||||
|
|
||||||
@interface Test: OFObject
|
@interface Test: OFObject <OFApplicationDelegate>
|
||||||
{
|
{
|
||||||
PGConnection *connection;
|
PGConnection *_connection;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -41,34 +41,34 @@ OF_APPLICATION_DELEGATE(Test)
|
||||||
[[OFApplication environment] objectForKey: @"USER"];
|
[[OFApplication environment] objectForKey: @"USER"];
|
||||||
PGResult *result;
|
PGResult *result;
|
||||||
|
|
||||||
connection = [[PGConnection alloc] init];
|
_connection = [[PGConnection alloc] init];
|
||||||
[connection setParameters:
|
[_connection setParameters:
|
||||||
[OFDictionary dictionaryWithKeysAndObjects: @"user", username,
|
[OFDictionary dictionaryWithKeysAndObjects: @"user", username,
|
||||||
@"dbname", username,
|
@"dbname", username,
|
||||||
nil]];
|
nil]];
|
||||||
[connection connect];
|
[_connection connect];
|
||||||
|
|
||||||
[connection executeCommand: @"DROP TABLE IF EXISTS test"];
|
[_connection executeCommand: @"DROP TABLE IF EXISTS test"];
|
||||||
[connection executeCommand: @"CREATE TABLE test ("
|
[_connection executeCommand: @"CREATE TABLE test ("
|
||||||
@" id integer,"
|
@" id integer,"
|
||||||
@" name varchar(255),"
|
@" name varchar(255),"
|
||||||
@" content text,"
|
@" content text,"
|
||||||
@" success boolean"
|
@" success boolean"
|
||||||
@")"];
|
@")"];
|
||||||
[connection executeCommand: @"INSERT INTO test (id, name, content) "
|
[_connection executeCommand: @"INSERT INTO test (id, name, content) "
|
||||||
@"VALUES ($1, $2, $3)"
|
@"VALUES ($1, $2, $3)"
|
||||||
parameters: [OFNumber numberWithInt: 1], @"foo",
|
parameters: [OFNumber numberWithInt: 1], @"foo",
|
||||||
@"Hallo Welt!", nil];
|
@"Hallo Welt!", nil];
|
||||||
[connection executeCommand: @"INSERT INTO test (id, content, success) "
|
[_connection executeCommand: @"INSERT INTO test (id, content, success) "
|
||||||
@"VALUES ($1, $2, $3)"
|
@"VALUES ($1, $2, $3)"
|
||||||
parameters: [OFNumber numberWithInt: 2],
|
parameters: [OFNumber numberWithInt: 2],
|
||||||
[OFNumber numberWithInt: 2],
|
[OFNumber numberWithInt: 2],
|
||||||
[OFNumber numberWithBool: true], nil];
|
[OFNumber numberWithBool: true], nil];
|
||||||
[connection insertRow: [OFDictionary dictionaryWithKeysAndObjects:
|
[_connection insertRow: [OFDictionary dictionaryWithKeysAndObjects:
|
||||||
@"content", @"Hallo!", @"name", @"foo", nil]
|
@"content", @"Hallo!", @"name", @"foo", nil]
|
||||||
intoTable: @"test"];
|
intoTable: @"test"];
|
||||||
|
|
||||||
result = [connection executeCommand: @"SELECT * FROM test"];
|
result = [_connection executeCommand: @"SELECT * FROM test"];
|
||||||
of_log(@"%@", result);
|
of_log(@"%@", result);
|
||||||
of_log(@"JSON: %@", [result JSONRepresentation]);
|
of_log(@"JSON: %@", [result JSONRepresentation]);
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ OF_APPLICATION_DELEGATE(Test)
|
||||||
for (id col in row)
|
for (id col in row)
|
||||||
of_log(@"%@", col);
|
of_log(@"%@", col);
|
||||||
|
|
||||||
result = [connection executeCommand: @"SELECT COUNT(*) FROM test"];
|
result = [_connection executeCommand: @"SELECT COUNT(*) FROM test"];
|
||||||
of_log(@"%@", result);
|
of_log(@"%@", result);
|
||||||
|
|
||||||
[OFApplication terminate];
|
[OFApplication terminate];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue