Skip to content

Commit

Permalink
migrate Databases test
Browse files Browse the repository at this point in the history
  • Loading branch information
tayloraswift committed Oct 24, 2024
1 parent ba4a0c1 commit 812a8fc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 37 deletions.
35 changes: 0 additions & 35 deletions Sources/MongoDBTests/Databases/Databases.swift

This file was deleted.

2 changes: 0 additions & 2 deletions Sources/MongoDBTests/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ enum Main:TestMain
[
ChangeStreams <ReplicatedConfiguration>.self,
Cursors <ReplicatedConfiguration>.self,
Databases <ReplicatedConfiguration>.self,
Fsync <ReplicatedConfiguration>.self,
Indexes <ReplicatedConfiguration>.self,

Expand All @@ -20,7 +19,6 @@ enum Main:TestMain
// complete cryptographic authentication, and the driver will time out before it
// completes.
Cursors <SingleConfiguration>.self,
Databases <SingleConfiguration>.self,
Fsync <SingleConfiguration>.self,
Indexes <SingleConfiguration>.self,
]
Expand Down
36 changes: 36 additions & 0 deletions Sources/MongoDBTests2/Databases.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import MongoDB
import Testing

@Suite
struct Databases:Mongo.TestBattery
{
let database:Mongo.Database = "Databases"

@Test(arguments: [.single, .replicated] as [any Mongo.TestConfiguration])
func databases(_ configuration:any Mongo.TestConfiguration) async throws
{
try await self.run(under: configuration)
}

func run(with pool:Mongo.SessionPool) async throws
{
let session:Mongo.Session = try await .init(from: pool)

try await session.run(
command: Mongo.Create<Mongo.Collection>.init("Placeholder"),
against: self.database)

let names:[Mongo.Database] = try await session.run(
command: Mongo.ListDatabases.NameOnly.init(),
against: .admin)

#expect(names.contains(self.database))

let (size, databases):(Int, [Mongo.DatabaseMetadata]) = try await session.run(
command: Mongo.ListDatabases.init(),
against: .admin)

#expect(size > 0)
#expect(databases.contains { $0.database == self.database })
}
}

0 comments on commit 812a8fc

Please sign in to comment.