aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/QueryKit/Tests
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2012-07-14 10:26:44 +0000
committerstuconnolly <stuart02@gmail.com>2012-07-14 10:26:44 +0000
commit6c1a1acdb2e030b08ccd08dc6eea70b3657ebb4c (patch)
treea2b9c82ab3db6f149ee6a67affd94ecda30a5b9b /Frameworks/QueryKit/Tests
parenta2d65d3fa1e58d91d47260cdbbbeae7c99aa04f8 (diff)
downloadsequelpro-6c1a1acdb2e030b08ccd08dc6eea70b3657ebb4c.tar.gz
sequelpro-6c1a1acdb2e030b08ccd08dc6eea70b3657ebb4c.tar.bz2
sequelpro-6c1a1acdb2e030b08ccd08dc6eea70b3657ebb4c.zip
Bunch of improvements including uderlying database system support.
Diffstat (limited to 'Frameworks/QueryKit/Tests')
-rw-r--r--Frameworks/QueryKit/Tests/QKQueryTests.m11
-rw-r--r--Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.m4
-rw-r--r--Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.m8
-rw-r--r--Frameworks/QueryKit/Tests/QKSelectQueryTests.m10
-rw-r--r--Frameworks/QueryKit/Tests/QKTestConstants.h2
-rw-r--r--Frameworks/QueryKit/Tests/QKUpdateQueryTests.m10
6 files changed, 27 insertions, 18 deletions
diff --git a/Frameworks/QueryKit/Tests/QKQueryTests.m b/Frameworks/QueryKit/Tests/QKQueryTests.m
index 63b0ec73..35212cff 100644
--- a/Frameworks/QueryKit/Tests/QKQueryTests.m
+++ b/Frameworks/QueryKit/Tests/QKQueryTests.m
@@ -40,7 +40,8 @@
{
_query = [QKQuery selectQueryFromTable:QKTestTableName];
- [_query setUseQuotes:NO];
+ [_query setUseQuotedIdentifiers:NO];
+ [_query setQueryDatabase:QKDatabaseMySQL];
[_query setDatabase:QKTestDatabaseName];
@@ -63,13 +64,17 @@
STAssertNil([_query table], @"query table");
STAssertNil([_query database], @"query database");
- STAssertTrue([_query useQuotes], @"query use quotes");
- STAssertTrue([_query queryType] == QKUnknownQuery, @"query type");
+
+ STAssertTrue([_query useQuotedIdentifiers], @"query use quoted identifiers");
+ STAssertTrue([[_query identifierQuote] isEqualToString:EMPTY_STRING], @"query identifier quote");
STAssertTrue([[_query fields] count] == 0, @"query fields");
STAssertTrue([[_query parameters] count] == 0, @"query parameters");
STAssertTrue([[_query updateParameters] count] == 0, @"query update parameters");
STAssertTrue([[_query groupByFields] count] == 0, @"query group by fields");
STAssertTrue([[_query orderByFields] count] == 0, @"query order by fields");
+
+ STAssertEquals([_query queryType], QKUnknownQuery, @"query type");
+ STAssertEquals([_query queryDatabase], QKDatabaseUnknown, @"query database");
}
@end
diff --git a/Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.m b/Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.m
index e9edbea1..c0ee4681 100644
--- a/Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.m
+++ b/Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.m
@@ -63,7 +63,7 @@
- (void)testSelectQueryGroupByWithoutQuotesIsCorrect
{
- [_query setUseQuotes:NO];
+ [_query setUseQuotedIdentifiers:NO];
[_query groupByField:QKTestFieldOne];
NSString *query = [NSString stringWithFormat:@"GROUP BY %@", QKTestFieldOne];
@@ -82,7 +82,7 @@
- (void)testSelectQueryGroupByMultipleFieldsWithoutQuotesIsCorrect
{
- [_query setUseQuotes:NO];
+ [_query setUseQuotedIdentifiers:NO];
[_query groupByFields:[NSArray arrayWithObjects:QKTestFieldOne, QKTestFieldTwo, nil]];
NSString *query = [NSString stringWithFormat:@"GROUP BY %@, %@", QKTestFieldOne, QKTestFieldTwo];
diff --git a/Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.m b/Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.m
index cb1a472f..4ea01e4a 100644
--- a/Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.m
+++ b/Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.m
@@ -63,7 +63,7 @@
- (void)testSelectQueryOrderByAscendingWithoutQuotesIsCorrect
{
- [_query setUseQuotes:NO];
+ [_query setUseQuotedIdentifiers:NO];
[_query orderByField:QKTestFieldOne descending:NO];
NSString *query = [NSString stringWithFormat:@"ORDER BY %@ ASC", QKTestFieldOne];
@@ -82,7 +82,7 @@
- (void)testSelectQueryOrderByMultipleFieldsAscendingWithoutQuotesIsCorrect
{
- [_query setUseQuotes:NO];
+ [_query setUseQuotedIdentifiers:NO];
[_query orderByFields:[NSArray arrayWithObjects:QKTestFieldOne, QKTestFieldTwo, nil] descending:NO];
NSString *query = [NSString stringWithFormat:@"ORDER BY %@, %@ ASC", QKTestFieldOne, QKTestFieldTwo];
@@ -101,7 +101,7 @@
- (void)testSelectQueryOrderByDescendingWithoutQuotesIsCorrect
{
- [_query setUseQuotes:NO];
+ [_query setUseQuotedIdentifiers:NO];
[_query orderByField:QKTestFieldOne descending:YES];
NSString *query = [NSString stringWithFormat:@"ORDER BY %@ DESC", QKTestFieldOne];
@@ -120,7 +120,7 @@
- (void)testSelectQueryOrderByMultipleFieldsDescendingWithoutQuotesIsCorrect
{
- [_query setUseQuotes:NO];
+ [_query setUseQuotedIdentifiers:NO];
[_query orderByFields:[NSArray arrayWithObjects:QKTestFieldOne, QKTestFieldTwo, nil] descending:YES];
NSString *query = [NSString stringWithFormat:@"ORDER BY %@, %@ DESC", QKTestFieldOne, QKTestFieldTwo];
diff --git a/Frameworks/QueryKit/Tests/QKSelectQueryTests.m b/Frameworks/QueryKit/Tests/QKSelectQueryTests.m
index 75cf7ed2..dc31d353 100644
--- a/Frameworks/QueryKit/Tests/QKSelectQueryTests.m
+++ b/Frameworks/QueryKit/Tests/QKSelectQueryTests.m
@@ -65,7 +65,7 @@
- (void)testSelectQueryFieldWithoutQuotesIsCorrect
{
- [_query setUseQuotes:NO];
+ [_query setUseQuotedIdentifiers:NO];
NSString *query = [NSString stringWithFormat:@"SELECT %@", QKTestFieldOne];
@@ -81,7 +81,7 @@
- (void)testSelectQueryMultipleFieldsWithoutQuotesAreCorrect
{
- [_query setUseQuotes:NO];
+ [_query setUseQuotedIdentifiers:NO];
NSString *query = [NSString stringWithFormat:@"SELECT %@, %@, %@, %@", QKTestFieldOne, QKTestFieldTwo, QKTestFieldThree, QKTestFieldFour];
@@ -90,16 +90,16 @@
- (void)testSelectQueryConstraintsAreCorrect
{
- NSString *query = [NSString stringWithFormat:@"WHERE `%@` %@ %@", QKTestFieldOne, [QKQueryUtilities operatorRepresentationForType:QKEqualityOperator], [NSNumber numberWithUnsignedInteger:QKTestParameterOne]];
+ NSString *query = [NSString stringWithFormat:@"WHERE `%@` %@ %@", QKTestFieldOne, [QKQueryUtilities stringRepresentationOfQueryOperator:QKEqualityOperator], [NSNumber numberWithUnsignedInteger:QKTestParameterOne]];
STAssertTrue(([[_query query] rangeOfString:query].location != NSNotFound), @"select query constraint");
}
- (void)testSelectQueryConstraintsWithoutQuotesAreCorrect
{
- [_query setUseQuotes:NO];
+ [_query setUseQuotedIdentifiers:NO];
- NSString *query = [NSString stringWithFormat:@"WHERE %@ %@ %@", QKTestFieldOne, [QKQueryUtilities operatorRepresentationForType:QKEqualityOperator], [NSNumber numberWithUnsignedInteger:QKTestParameterOne]];
+ NSString *query = [NSString stringWithFormat:@"WHERE %@ %@ %@", QKTestFieldOne, [QKQueryUtilities stringRepresentationOfQueryOperator:QKEqualityOperator], [NSNumber numberWithUnsignedInteger:QKTestParameterOne]];
STAssertTrue(([[_query query] rangeOfString:query].location != NSNotFound), @"select query constraint without quotes");
}
diff --git a/Frameworks/QueryKit/Tests/QKTestConstants.h b/Frameworks/QueryKit/Tests/QKTestConstants.h
index 10e3fa7e..7c200d3e 100644
--- a/Frameworks/QueryKit/Tests/QKTestConstants.h
+++ b/Frameworks/QueryKit/Tests/QKTestConstants.h
@@ -28,6 +28,8 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
+#define EMPTY_STRING @""
+
extern NSString *QKTestDatabaseName;
extern NSString *QKTestTableName;
diff --git a/Frameworks/QueryKit/Tests/QKUpdateQueryTests.m b/Frameworks/QueryKit/Tests/QKUpdateQueryTests.m
index 6a24881d..65c31dae 100644
--- a/Frameworks/QueryKit/Tests/QKUpdateQueryTests.m
+++ b/Frameworks/QueryKit/Tests/QKUpdateQueryTests.m
@@ -65,25 +65,27 @@
- (void)testUpdateQueryFieldsWithoutQuotesAreCorrect
{
- [_query setUseQuotes:NO];
+ [_query setUseQuotedIdentifiers:NO];
NSString *query = [NSString stringWithFormat:@"UPDATE %@ SET %@ = '%@', %@ = '%@'", QKTestTableName, QKTestFieldOne, QKTestUpdateValueOne, QKTestFieldTwo, QKTestUpdateValueTwo];
+ NSLog(@"%@", [_query query]);
+
STAssertTrue([[_query query] hasPrefix:query], @"update query fields without quotes");
}
- (void)testUpdateQueryConstraintIsCorrect
{
- NSString *query = [NSString stringWithFormat:@"WHERE `%@` %@ %@", QKTestFieldOne, [QKQueryUtilities operatorRepresentationForType:QKEqualityOperator], [NSNumber numberWithUnsignedInteger:QKTestParameterOne]];
+ NSString *query = [NSString stringWithFormat:@"WHERE `%@` %@ %@", QKTestFieldOne, [QKQueryUtilities stringRepresentationOfQueryOperator:QKEqualityOperator], [NSNumber numberWithUnsignedInteger:QKTestParameterOne]];
STAssertTrue(([[_query query] rangeOfString:query].location != NSNotFound), @"update query constraint");
}
- (void)testUpdateQueryConstraintWithoutQuotesIsCorrect
{
- [_query setUseQuotes:NO];
+ [_query setUseQuotedIdentifiers:NO];
- NSString *query = [NSString stringWithFormat:@"WHERE %@ %@ %@", QKTestFieldOne, [QKQueryUtilities operatorRepresentationForType:QKEqualityOperator], [NSNumber numberWithUnsignedInteger:QKTestParameterOne]];
+ NSString *query = [NSString stringWithFormat:@"WHERE %@ %@ %@", QKTestFieldOne, [QKQueryUtilities stringRepresentationOfQueryOperator:QKEqualityOperator], [NSNumber numberWithUnsignedInteger:QKTestParameterOne]];
STAssertTrue(([[_query query] rangeOfString:query].location != NSNotFound), @"update query constraint without quotes");
}