From 4400b0e1db8876a1fdacb30eea3ec89fa875f3c6 Mon Sep 17 00:00:00 2001 From: Erick Date: Tue, 18 Jun 2024 14:15:41 -0300 Subject: [PATCH] fix: e2e tests (#2259) --- .github/workflows/e2e.yaml | 4 +++- .../shorebird_cli_cache_test.dart | 20 +++++++++++++------ .../shorebird_cli_integration_test.dart | 6 +++++- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 33158ac0..c8153628 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -144,5 +144,7 @@ jobs: cache: true - name: 🧪 Run Integration Tests - run: dart test integration_test + # Run a single test at a time to ensure that one test does not interfere with another + # since some commands might change the state of the cli installation. + run: dart test integration_test -j 1 working-directory: packages/shorebird_cli diff --git a/packages/shorebird_cli/integration_test/shorebird_cli_cache_test.dart b/packages/shorebird_cli/integration_test/shorebird_cli_cache_test.dart index 1e0d0738..95a2c1ab 100644 --- a/packages/shorebird_cli/integration_test/shorebird_cli_cache_test.dart +++ b/packages/shorebird_cli/integration_test/shorebird_cli_cache_test.dart @@ -24,13 +24,21 @@ R runWithOverrides(R Function() body) { void main() { group('shorebird cache', () { - test('can clear the cache', () { - final result = runCommand( - 'shorebird cache clear', - workingDirectory: '.', - ); + group('clear', () { + tearDown(() { + // Run an arbritery, fast command, so cache will be restored + // for the next test. + runCommand('--version', workingDirectory: '.'); + }); - expect(result.exitCode, equals(ExitCode.success.code)); + test('can clear the cache', () { + final result = runCommand( + 'shorebird cache clear', + workingDirectory: '.', + ); + + expect(result.exitCode, equals(ExitCode.success.code)); + }); }); }); } diff --git a/packages/shorebird_cli/integration_test/shorebird_cli_integration_test.dart b/packages/shorebird_cli/integration_test/shorebird_cli_integration_test.dart index fb2c6b0f..2b70e7aa 100644 --- a/packages/shorebird_cli/integration_test/shorebird_cli_integration_test.dart +++ b/packages/shorebird_cli/integration_test/shorebird_cli_integration_test.dart @@ -32,11 +32,15 @@ R runWithOverrides(R Function() body) { } void main() { + final shorebirdHostedURL = Platform.environment['SHOREBIRD_HOSTED_URL']; + if (shorebirdHostedURL == null || shorebirdHostedURL.isEmpty) { + throw Exception('SHOREBIRD_HOSTED_URL environment variable is not set.'); + } final logger = Logger(); final client = runWithOverrides( () => CodePushClient( httpClient: Auth().client, - hostedUri: Uri.parse(Platform.environment['SHOREBIRD_HOSTED_URL']!), + hostedUri: Uri.parse(shorebirdHostedURL), ), );