aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/QueryKit/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Frameworks/QueryKit/Tests')
-rw-r--r--Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.h4
-rw-r--r--Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.m4
-rw-r--r--Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.h4
-rw-r--r--Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.m4
-rw-r--r--Frameworks/QueryKit/Tests/QKSelectQueryTests.h4
-rw-r--r--Frameworks/QueryKit/Tests/QKSelectQueryTests.m4
-rw-r--r--Frameworks/QueryKit/Tests/QKUpdateQueryTests.h39
-rw-r--r--Frameworks/QueryKit/Tests/QKUpdateQueryTests.m82
8 files changed, 127 insertions, 18 deletions
diff --git a/Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.h b/Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.h
index 56907b36..1be5345b 100644
--- a/Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.h
+++ b/Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.h
@@ -2,7 +2,7 @@
// $Id$
//
// QKSelectQueryGroupByTests.h
-// sequel-pro
+// QueryKit
//
// Created by Stuart Connolly (stuconnolly.com) on February 25, 2012
// Copyright (c) 2012 Stuart Connolly. All rights reserved.
@@ -27,8 +27,6 @@
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
-//
-// More info at <http://code.google.com/p/sequel-pro/>
#import <QueryKit/QueryKit.h>
#import <SenTestingKit/SenTestingKit.h>
diff --git a/Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.m b/Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.m
index 9bbe75a2..0a8277e0 100644
--- a/Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.m
+++ b/Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.m
@@ -2,7 +2,7 @@
// $Id$
//
// QKSelectQueryGroupByTests.m
-// sequel-pro
+// QueryKit
//
// Created by Stuart Connolly (stuconnolly.com) on February 25, 2012
// Copyright (c) 2012 Stuart Connolly. All rights reserved.
@@ -27,8 +27,6 @@
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
-//
-// More info at <http://code.google.com/p/sequel-pro/>
#import "QKSelectQueryGroupByTests.h"
diff --git a/Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.h b/Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.h
index c457491a..1ced6503 100644
--- a/Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.h
+++ b/Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.h
@@ -2,7 +2,7 @@
// $Id$
//
// QKSelectQueryOrderByTests.h
-// sequel-pro
+// QueryKit
//
// Created by Stuart Connolly (stuconnolly.com) on February 25, 2012
// Copyright (c) 2012 Stuart Connolly. All rights reserved.
@@ -27,8 +27,6 @@
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
-//
-// More info at <http://code.google.com/p/sequel-pro/>
#import <QueryKit/QueryKit.h>
#import <SenTestingKit/SenTestingKit.h>
diff --git a/Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.m b/Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.m
index 84bd5ddb..ac70f0fe 100644
--- a/Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.m
+++ b/Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.m
@@ -2,7 +2,7 @@
// $Id$
//
// QKSelectQueryOrderByTests.m
-// sequel-pro
+// QueryKit
//
// Created by Stuart Connolly (stuconnolly.com) on February 25, 2012
// Copyright (c) 2012 Stuart Connolly. All rights reserved.
@@ -27,8 +27,6 @@
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
-//
-// More info at <http://code.google.com/p/sequel-pro/>
#import "QKSelectQueryOrderByTests.h"
diff --git a/Frameworks/QueryKit/Tests/QKSelectQueryTests.h b/Frameworks/QueryKit/Tests/QKSelectQueryTests.h
index df9e3272..80ea92e2 100644
--- a/Frameworks/QueryKit/Tests/QKSelectQueryTests.h
+++ b/Frameworks/QueryKit/Tests/QKSelectQueryTests.h
@@ -2,7 +2,7 @@
// $Id$
//
// QKSelectQueryTests.h
-// sequel-pro
+// QueryKit
//
// Created by Stuart Connolly (stuconnolly.com) on September 4, 2011
// Copyright (c) 2011 Stuart Connolly. All rights reserved.
@@ -27,8 +27,6 @@
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
-//
-// More info at <http://code.google.com/p/sequel-pro/>
#import <QueryKit/QueryKit.h>
#import <SenTestingKit/SenTestingKit.h>
diff --git a/Frameworks/QueryKit/Tests/QKSelectQueryTests.m b/Frameworks/QueryKit/Tests/QKSelectQueryTests.m
index 620dbadd..cb2d3599 100644
--- a/Frameworks/QueryKit/Tests/QKSelectQueryTests.m
+++ b/Frameworks/QueryKit/Tests/QKSelectQueryTests.m
@@ -2,7 +2,7 @@
// $Id$
//
// QKSelectQueryTests.m
-// sequel-pro
+// QueryKit
//
// Created by Stuart Connolly (stuconnolly.com) on September 4, 2011
// Copyright (c) 2011 Stuart Connolly. All rights reserved.
@@ -27,8 +27,6 @@
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
-//
-// More info at <http://code.google.com/p/sequel-pro/>
#import "QKSelectQueryTests.h"
diff --git a/Frameworks/QueryKit/Tests/QKUpdateQueryTests.h b/Frameworks/QueryKit/Tests/QKUpdateQueryTests.h
new file mode 100644
index 00000000..b4230c1f
--- /dev/null
+++ b/Frameworks/QueryKit/Tests/QKUpdateQueryTests.h
@@ -0,0 +1,39 @@
+//
+// $Id$
+//
+// QKUpdateQueryTests.h
+// QueryKit
+//
+// Created by Stuart Connolly (stuconnolly.com) on March 25, 2012
+// Copyright (c) 2012 Stuart Connolly. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+
+#import <QueryKit/QueryKit.h>
+#import <SenTestingKit/SenTestingKit.h>
+
+@interface QKUpdateQueryTests : SenTestCase
+{
+ QKQuery *_query;
+}
+
+@end
diff --git a/Frameworks/QueryKit/Tests/QKUpdateQueryTests.m b/Frameworks/QueryKit/Tests/QKUpdateQueryTests.m
new file mode 100644
index 00000000..fa3bb766
--- /dev/null
+++ b/Frameworks/QueryKit/Tests/QKUpdateQueryTests.m
@@ -0,0 +1,82 @@
+//
+// $Id$
+//
+// QKUpdateQueryTests.m
+// QueryKit
+//
+// Created by Stuart Connolly (stuconnolly.com) on March 25, 2012
+// Copyright (c) 2012 Stuart Connolly. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+
+#import "QKUpdateQueryTests.h"
+
+static NSString *QKTestTableName = @"test_table";
+
+static NSString *QKTestFieldOne = @"test_field1";
+static NSString *QKTestFieldTwo = @"test_field2";
+
+static NSString *QKTestUpdateValueOne = @"update_one";
+static NSString *QKTestUpdateValueTwo = @"update_two";
+
+static NSUInteger QKTestParameterOne = 10;
+
+@implementation QKUpdateQueryTests
+
+#pragma mark -
+#pragma mark Setup & tear down
+
+- (void)setUp
+{
+ _query = [QKQuery queryTable:QKTestTableName];
+
+ [_query setQueryType:QKUpdateQuery];
+
+ [_query addFieldToUpdate:QKTestFieldOne toValue:QKTestUpdateValueOne];
+ [_query addFieldToUpdate:QKTestFieldTwo toValue:QKTestUpdateValueTwo];
+
+ [_query addParameter:QKTestFieldOne operator:QKEqualityOperator value:[NSNumber numberWithUnsignedInteger:QKTestParameterOne]];
+}
+
+#pragma mark -
+#pragma mark Tests
+
+- (void)testUpdateQueryTypeIsCorrect
+{
+ STAssertTrue([[_query query] hasPrefix:@"UPDATE"], @"query type");
+}
+
+- (void)testUpdateQueryFieldsAreCorrect
+{
+ NSString *query = [NSString stringWithFormat:@"UPDATE %@ SET %@ = '%@', %@ = '%@'", QKTestTableName, QKTestFieldOne, QKTestUpdateValueOne, QKTestFieldTwo, QKTestUpdateValueTwo];
+
+ STAssertTrue([[_query query] hasPrefix:query], @"query fields");
+}
+
+- (void)testUpdateQueryConstraintsAreCorrect
+{
+ NSString *query = [NSString stringWithFormat:@"WHERE %@ %@ %@", QKTestFieldOne, [QKQueryUtilities operatorRepresentationForType:QKEqualityOperator], [NSNumber numberWithUnsignedInteger:QKTestParameterOne]];
+
+ STAssertTrue(([[_query query] rangeOfString:query].location != NSNotFound), @"query constraints");
+}
+
+@end