diff --git a/Sources/MongoSwift/BSON/Document.swift b/Sources/MongoSwift/BSON/Document.swift index b9e098539..b923987fd 100644 --- a/Sources/MongoSwift/BSON/Document.swift +++ b/Sources/MongoSwift/BSON/Document.swift @@ -545,24 +545,6 @@ internal func withMutableBSONPointer( return try body(document._storage._bson) } -/// An extension of `Document` to add the capability to be initialized with an array literal. -extension Document: ExpressibleByArrayLiteral { - /** - * Initializes a `Document` using an array literal where the values - * are `BSONValue`s. Values are stored under a string of their - * index in the array. For example: - * `d: Document = ["a", "b"]` will become `["0": "a", "1": "b"]` - * - * - Parameters: - * - arrayLiteral: a `[BSONValue]` - * - * - Returns: a new `Document` - */ - public init(arrayLiteral elements: BSON...) { - self.init(elements) - } -} - // An extension of `Document` to add the capability to be hashed extension Document: Hashable { public func hash(into hasher: inout Hasher) { diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift index 9e0d2631b..bc3617228 100644 --- a/Tests/LinuxMain.swift +++ b/Tests/LinuxMain.swift @@ -111,7 +111,6 @@ extension DocumentTests { static var allTests = [ ("testDocument", testDocument), ("testDocumentDynamicMemberLookup", testDocumentDynamicMemberLookup), - ("testDocumentFromArray", testDocumentFromArray), ("testEquatable", testEquatable), ("testRawBSON", testRawBSON), ("testValueBehavior", testValueBehavior), diff --git a/Tests/MongoSwiftTests/Document+SequenceTests.swift b/Tests/MongoSwiftTests/Document+SequenceTests.swift index a45e2da8d..615d31bcf 100644 --- a/Tests/MongoSwiftTests/Document+SequenceTests.swift +++ b/Tests/MongoSwiftTests/Document+SequenceTests.swift @@ -262,7 +262,7 @@ final class Document_SequenceTests: MongoSwiftTestCase { expect(self.smallDoc.suffix(2)).to(equal(self.smallDoc)) expect(self.smallDoc.suffix(5)).to(equal(self.smallDoc)) - expect(self.doc.suffix(0)).to(equal([])) + expect(self.doc.suffix(0)).to(equal([:])) expect(self.doc.suffix(1)).to(equal(["g": 10])) expect(self.doc.suffix(2)).to(equal(["f": .minKey, "g": 10])) expect(self.doc.suffix(4)).to(equal(["d": false, "e": .null, "f": .minKey, "g": 10])) diff --git a/Tests/MongoSwiftTests/DocumentTests.swift b/Tests/MongoSwiftTests/DocumentTests.swift index 9177ef63c..a7aee581d 100644 --- a/Tests/MongoSwiftTests/DocumentTests.swift +++ b/Tests/MongoSwiftTests/DocumentTests.swift @@ -243,23 +243,6 @@ final class DocumentTests: MongoSwiftTestCase { expect(doc.b).to(equal("different")) } - func testDocumentFromArray() { - let doc1: Document = ["foo", .minKey, .null] - - expect(doc1.keys).to(equal(["0", "1", "2"])) - expect(doc1["0"]).to(equal("foo")) - expect(doc1["1"]).to(equal(.minKey)) - expect(doc1["2"]).to(equal(.null)) - - let elements: [BSON] = ["foo", .minKey, .null] - let doc2 = Document(elements) - - expect(doc2.keys).to(equal(["0", "1", "2"])) - expect(doc2["0"]).to(equal("foo")) - expect(doc2["1"]).to(equal(.minKey)) - expect(doc2["2"]).to(equal(.null)) - } - func testEquatable() { expect(["hi": true, "hello": "hi", "cat": 2] as Document) .to(equal(["hi": true, "hello": "hi", "cat": 2] as Document)) diff --git a/Tests/MongoSwiftTests/ReadPreferenceTests.swift b/Tests/MongoSwiftTests/ReadPreferenceTests.swift index 5d82ff7ed..342adebd6 100644 --- a/Tests/MongoSwiftTests/ReadPreferenceTests.swift +++ b/Tests/MongoSwiftTests/ReadPreferenceTests.swift @@ -31,16 +31,16 @@ final class ReadPreferenceTests: MongoSwiftTestCase { let rpNoTagSets = try ReadPreference(.nearest, tagSets: nil) expect(rpNoTagSets.tagSets).to(equal([])) - let rpSomeTagSets = try ReadPreference(.nearest, tagSets: [["dc": "east"], []]) - expect(rpSomeTagSets.tagSets).to(equal([["dc": "east"], []])) + let rpSomeTagSets = try ReadPreference(.nearest, tagSets: [["dc": "east"], [:]]) + expect(rpSomeTagSets.tagSets).to(equal([["dc": "east"], [:]])) - let rpOnlyEmptyTagSet = try ReadPreference(.nearest, tagSets: [[]]) - expect(rpOnlyEmptyTagSet.tagSets).to(equal([[]])) + let rpOnlyEmptyTagSet = try ReadPreference(.nearest, tagSets: [[:]]) + expect(rpOnlyEmptyTagSet.tagSets).to(equal([[:]])) // Non-empty tag sets cannot be combined with primary mode - expect(try ReadPreference(.primary, tagSets: [["dc": "east"], []])) + expect(try ReadPreference(.primary, tagSets: [["dc": "east"], [:]])) .to(throwError(UserError.invalidArgumentError(message: ""))) - expect(try ReadPreference(.primary, tagSets: [[]])).to(throwError(UserError.invalidArgumentError(message: ""))) + expect(try ReadPreference(.primary, tagSets: [[:]])).to(throwError(UserError.invalidArgumentError(message: ""))) } func testMaxStalenessSeconds() throws { @@ -80,11 +80,11 @@ final class ReadPreferenceTests: MongoSwiftTestCase { .to(equal(ReadPreference(.secondary))) expect(try ReadPreference(.secondary, tagSets: [])) .to(equal(try ReadPreference(.secondary, tagSets: []))) - expect(try ReadPreference(.secondary, tagSets: [["dc": "east"], []])) - .to(equal(try ReadPreference(.secondary, tagSets: [["dc": "east"], []]))) - expect(try ReadPreference(.secondary, tagSets: [["dc": "east"], []])) - .toNot(equal(try ReadPreference(.nearest, tagSets: [["dc": "east"], []]))) - expect(try ReadPreference(.secondary, tagSets: [["dc": "east"], []])) + expect(try ReadPreference(.secondary, tagSets: [["dc": "east"], [:]])) + .to(equal(try ReadPreference(.secondary, tagSets: [["dc": "east"], [:]]))) + expect(try ReadPreference(.secondary, tagSets: [["dc": "east"], [:]])) + .toNot(equal(try ReadPreference(.nearest, tagSets: [["dc": "east"], [:]]))) + expect(try ReadPreference(.secondary, tagSets: [["dc": "east"], [:]])) .toNot(equal(try ReadPreference(.secondary, maxStalenessSeconds: 90))) expect(try ReadPreference(.secondaryPreferred, maxStalenessSeconds: nil))