Skip to content

test: eliminate AsyncFeatureSpec test-setup family (convert async suites to sync) #30

Description

@hongwei1

Background

During the dispatch-core → OkHttp3 migration (#9, PR #28), a family of *ServerSetupAsync test-setup traits and async-style test suites survived in the test tree.

Clarification: the "Async" here is ScalaTest's AsyncFeatureSpec test-writing style (test bodies return Future[Assertion]), not the dispatch/AsyncHttpClient HTTP client (removed in #9) and not the http4s server framework. The async request helpers (makePostRequestAsync etc.) are fake-asyncFuture { blocking { syncCall } } wrappers. No real concurrent I/O happens in these suites.

Goal

Fully remove the async test-setup style: convert all async-style suites to ordinary synchronous suites, then delete the async setup traits.

Scope

Keep (do NOT touch)

  • SendServerRequests async request methods (makeGetRequestAsync / makePostRequestAsync / makePutRequestAsync / makeDeleteRequestAsync / getAPIResponseAsync) — still used by the genuine concurrency tests (code.concurrency.Concurrent*Test, which extend ConcurrentRaceSetup, not ServerSetupAsync).

Convert to sync (9 suites)

  • v4_0_0: PasswordRecoverTest, EntitlementTests, BankTests, ConsentTests
  • v5_0_0: BankTests, ConsentRequestTest, ATMTest, UserAuthContextTest, CustomerTest

Conversion patterns:

  1. Mechanical unwrapmakeXxxRequestAsyncmakeXxxRequest, collapse response map { r => … } into direct response.….
  2. for-comprehension with real production Futures (v4/v5 BankTests) — Await.result the genuine NewStyle.function.* Futures, sync test requests, inline assertions.
  3. Pure trait switch — suites that extend an Async trait but already write sync assertions (lifted by convertAssertionToFutureAssertion): just switch VxxxServerSetupAsyncVxxxServerSetup.

Delete (6 files)

  • v3_0_0/WarehouseTestAsync.scala (redundant with existing sync WarehouseTest)
  • v3_0_0/V300ServerSetupAsync.scala
  • v3_1_0/V310ServerSetupAsync.scala (already dead — zero references)
  • v4_0_0/V400ServerSetupAsync.scala
  • v5_0_0/V500ServerSetupAsync.scala
  • setup/ServerSetupAsync.scala (both ServerSetupAsync + ServerSetupWithTestDataAsync)

Verification

  • mvn test-compile zero errors
  • Affected v3/v4/v5 suites green
  • Concurrency tests still green (async helpers retained)
  • Full local run_tests_parallel.sh gate green

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions