Skip to content

Make DataSourceTests.testSendable properly async #136

@leogdion

Description

@leogdion

Severity: 🟡 Minor
File: Tests/BushelFoundationTests/DataSourceTests.swift:91
PR: #126

Issue

The testSendable() test creates a Task without awaiting it, which means the assertion may not execute before the test completes. This could lead to the test passing even if the assertion would fail.

Current Code

internal func testSendable() {
  // Compile-time check that DataSource is Sendable
  Task {
    let source = DataSource.appleDB
    XCTAssertEqual(source.rawValue, "appledb.dev")
  }
}

Recommended Fix

Mark the test as async and await the Task to ensure execution:

internal func testSendable() async {
  // Compile-time check that DataSource is Sendable
  await Task {
    let source = DataSource.appleDB
    XCTAssertEqual(source.rawValue, "appledb.dev")
  }.value
}

CodeRabbit Suggestion

In @Tests/BushelFoundationTests/DataSourceTests.swift around lines 85-91, The
test testSendable uses Task { ... } without awaiting it, so the assertion may
run after the test exits; make the test function async (change signature of
testSendable to async) and either await the Task (e.g., let _ = await Task { ...
}.value) or remove the Task and perform the assertion directly (use await where
needed) to ensure the XCTAssertEqual on DataSource.appleDB.rawValue runs before
the test completes.

Source: CodeRabbit AI review of PR #126

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions