Permalink
Browse files

Updated RKOAuthClientTest to check for the availability of MongoDB an…

…d log a warning message if it is not available. This prevents broken test failures because MongoDB is not installed or running. refs #714
  • Loading branch information...
1 parent ec4db41 commit 6ca3d1f5aca717c3f75e90b34e5b17f433092faf @blakewatters blakewatters committed May 10, 2012
Showing with 24 additions and 1 deletion.
  1. +24 −1 Tests/Logic/Network/RKOAuthClientTest.m
View
25 Tests/Logic/Network/RKOAuthClientTest.m
@@ -19,14 +19,33 @@
//
#import "RKTestEnvironment.h"
+#import "RKPortCheck.h"
+
+#define RKOAuthClientTestSkipWithoutMongoDB() \
+ if (! [self isMongoRunning]) { \
+ NSLog(@"!! Skipping OAuth Test: MongoDB not running"); \
+ return; \
+ }
@interface RKOAuthClientTest : RKTestCase
@end
@implementation RKOAuthClientTest
+- (BOOL)isMongoRunning {
+ static RKPortCheck *portCheck = nil;
+ if (! portCheck) {
+ portCheck = [[RKPortCheck alloc] initWithHost:@"localhost" port:27017];
+ [portCheck run];
+ }
+
+ return [portCheck isOpen];
+}
+
- (void)testShouldGetAccessToken{
+ RKOAuthClientTestSkipWithoutMongoDB();
+
RKTestResponseLoader *loader = [RKTestResponseLoader responseLoader];
RKOAuthClient *client = RKTestNewOAuthClient(loader);
client.authorizationCode = @"4fa8182d7184797dd5000002";
@@ -36,7 +55,9 @@ - (void)testShouldGetAccessToken{
assertThatBool(loader.wasSuccessful, is(equalToBool(YES)));
}
-- (void)testShouldNotGetAccessToken{
+- (void)testShouldNotGetAccessToken {
+ RKOAuthClientTestSkipWithoutMongoDB();
+
RKTestResponseLoader *loader = [RKTestResponseLoader responseLoader];
RKOAuthClient *client = RKTestNewOAuthClient(loader);
client.authorizationCode = @"someInvalidAuthorizationCode";
@@ -48,6 +69,8 @@ - (void)testShouldNotGetAccessToken{
}
- (void)testShouldGetProtectedResource{
+ RKOAuthClientTestSkipWithoutMongoDB();
+
//TODO: Encapsulate this code in a correct manner
RKTestResponseLoader *loader = [RKTestResponseLoader responseLoader];
RKOAuthClient *client = RKTestNewOAuthClient(loader);

0 comments on commit 6ca3d1f

Please sign in to comment.