Skip to content

Commit

Permalink
Fix SPM test compilation for iOS (#7066)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgoyne committed Jan 25, 2021
1 parent 340d916 commit e5d40c1
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Realm/ObjectServerTests/RLMBSONTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ - (void)testObjectIdRoundTrip {
auto bson = Bson(realm::ObjectId::gen());
RLMObjectId *rlm = (RLMObjectId *)RLMConvertBsonToRLMBSON(bson);
RLMObjectId *d = [[RLMObjectId alloc] initWithString:rlm.stringValue error:nil];
XCTAssert([rlm isEqualTo: d]);
XCTAssertEqualObjects(rlm, d);
XCTAssertEqual(RLMConvertRLMBSONToBson(rlm), bson);
}

Expand Down
6 changes: 5 additions & 1 deletion Realm/ObjectServerTests/RLMObjectServerTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#import <realm/object-store/shared_realm.hpp>
#import <realm/object-store/sync/sync_manager.hpp>

#if TARGET_OS_OSX

#pragma mark - Helpers

// These are defined in Swift. Importing the auto-generated header doesn't work
Expand Down Expand Up @@ -124,7 +126,7 @@ - (void)testLogoutSpecificUser {
RLMUser *secondUser = [self logInUserForCredentials:[self basicCredentialsWithName:@"test1@10gen.com"
register:YES]];

XCTAssertTrue([[self.app currentUser].identifier isEqualTo:secondUser.identifier]);
XCTAssertEqualObjects(self.app.currentUser.identifier, secondUser.identifier);
// `[app currentUser]` will now be `secondUser`, so let's logout firstUser and ensure
// the state is correct
XCTestExpectation *expectation = [self expectationWithDescription:@"should log out current user"];
Expand Down Expand Up @@ -2526,3 +2528,5 @@ - (void)testLegacyFilePathsAreUsedIfFilesArePresent {
}

@end

#endif // TARGET_OS_OSX
4 changes: 4 additions & 0 deletions Realm/ObjectServerTests/RLMSyncTestCase.mm
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#import <realm/object-store/sync/sync_session.hpp>
#import <realm/object-store/sync/sync_user.hpp>

#if TARGET_OS_OSX

@interface RealmServer : NSObject
+ (RealmServer *)shared;
+ (bool)haveServer;
Expand Down Expand Up @@ -558,3 +560,5 @@ - (NSTask *)childTask {
}

@end

#endif // TARGET_OS_OSX
4 changes: 4 additions & 0 deletions Realm/ObjectServerTests/RealmServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import Foundation
import RealmSwift
import XCTest

#if os(macOS)

extension URLSession {
fileprivate func resultDataTask(with request: URLRequest, _ completionHandler: @escaping (Result<Data, Error>) -> Void) {
URLSession(configuration: .default, delegate: nil, delegateQueue: OperationQueue()).dataTask(with: request) { (data, response, error) in
Expand Down Expand Up @@ -805,3 +807,5 @@ public class RealmServer: NSObject {
return clientAppId
}
}

#endif
4 changes: 4 additions & 0 deletions Realm/ObjectServerTests/SwiftObjectServerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
//
////////////////////////////////////////////////////////////////////////////

#if os(macOS)

import Combine
import Realm
import RealmSwift
Expand Down Expand Up @@ -2784,3 +2786,5 @@ class CombineObjectServerTests: SwiftSyncTestCase {
}
}
#endif

#endif // os(macOS)
4 changes: 4 additions & 0 deletions Realm/ObjectServerTests/SwiftSyncTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
//
////////////////////////////////////////////////////////////////////////////

#if os(macOS)

import XCTest
import RealmSwift

Expand Down Expand Up @@ -164,3 +166,5 @@ open class SwiftSyncTestCase: RLMSyncTestCase {
}
}
}

#endif // os(macOS)
4 changes: 4 additions & 0 deletions Realm/ObjectServerTests/TimeoutProxyServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
//
////////////////////////////////////////////////////////////////////////////

#if os(macOS)

import Foundation
import Network

Expand Down Expand Up @@ -88,3 +90,5 @@ public class TimeoutProxyServer: NSObject {
}
}
}

#endif // os(macOS)
2 changes: 0 additions & 2 deletions Realm/RLMUtil.mm
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,6 @@ id RLMMixedToObjc(realm::Mixed const& mixed) {
return [[RLMObjectId alloc] initWithValue:mixed.get<realm::ObjectId>()];
case realm::type_Link:
case realm::type_LinkList:
case realm::type_OldTable:
case realm::type_OldDateTime:
REALM_UNREACHABLE();
default:
@throw RLMException(@"Invalid data type for RLMPropertyTypeAny property.");
Expand Down

0 comments on commit e5d40c1

Please sign in to comment.