Skip to content

Commit

Permalink
reproduction of issue 106: no history available when repo.find() is i…
Browse files Browse the repository at this point in the history
…nvoked and the repo has a storage provider (#113)

* reproduction of issue #106 
* adding test from Jesse showing failure to initiate and automatically sync on two independent imports
* explicitly initiate a sync on create, import, or clone with all connected peers
* replacing integration test helper with upstream utility method
* renaming test classes to distinguish more easily between single and dual client tests
* fixing mismatched assumptions about documents being created automatically vs reporting they don't exist
* updating tests to align with changed behaviors for sync on create/import/clone
* in the scenario where a document is sync'd on creation, and a peer is connected, the other peer will have a record of the document to return an immediate result on find(), but the contents won't be completely up to date until the sync has processed. 
  * The updated tests (unit and integration) verify that a sync happens, but there's no clear indicator of "I'm up to date with all my peers" right now.
  • Loading branch information
heckj authored Jul 4, 2024
1 parent 74e837e commit c3211ed
Show file tree
Hide file tree
Showing 15 changed files with 448 additions and 215 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ extension RepoPeer2PeerIntegrationTests {

let requestedDoc = try await repoBob.find(id: handle.id)
XCTAssertEqual(requestedDoc.id, handle.id)
XCTAssertTrue(RepoHelpers.equalContents(doc1: requestedDoc.doc, doc2: handle.doc))
XCTAssertTrue(requestedDoc.doc.equivalentContents(handle.doc))

// MARK: cleanup and teardown

Expand Down

This file was deleted.

10 changes: 0 additions & 10 deletions IntegrationTests/Tests/IntegrationTestsTests/RepoHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,4 @@ public enum RepoHelpers {
try newDoc.updateText(obj: txt, value: "Hello World!")
return DocHandle(id: DocumentId(), doc: newDoc)
}

static func equalContents(doc1: Document, doc2: Document) -> Bool {
do {
let doc1Contents = try doc1.parseToSchema(doc1, from: .ROOT)
let doc2Contents = try doc2.parseToSchema(doc1, from: .ROOT)
return doc1Contents == doc2Contents
} catch {
return false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import XCTest
// repository, run the `./scripts/interop.sh` script to start up a local instance to
// respond.

final class RepoWebsocketIntegrationTests: XCTestCase {
final class Repo_OneClient_WebsocketIntegrationTests: XCTestCase {
private static let subsystem = Bundle.main.bundleIdentifier!

static let test = Logger(subsystem: subsystem, category: "WebSocketSyncIntegrationTests")
Expand Down Expand Up @@ -100,7 +100,7 @@ final class RepoWebsocketIntegrationTests: XCTestCase {

let foundDocHandle = try await repoTwo.find(id: handle.id)
XCTAssertEqual(foundDocHandle.id, handle.id)
XCTAssertTrue(RepoHelpers.equalContents(doc1: foundDocHandle.doc, doc2: handle.doc))
XCTAssertTrue(foundDocHandle.doc.equivalentContents(handle.doc))
}

func testFindWithRandomId() async throws {
Expand Down
Loading

0 comments on commit c3211ed

Please sign in to comment.