diff --git a/packages/stac_cli/pubspec.lock b/packages/stac_cli/pubspec.lock index 4fe9fd6b..abef6e2b 100644 --- a/packages/stac_cli/pubspec.lock +++ b/packages/stac_cli/pubspec.lock @@ -101,10 +101,10 @@ packages: dependency: transitive description: name: characters - sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 url: "https://pub.dev" source: hosted - version: "1.4.1" + version: "1.4.0" checked_yaml: dependency: transitive description: @@ -241,6 +241,11 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.1" + flutter: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" frontend_server_client: dependency: transitive description: @@ -353,6 +358,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.12.19" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.dev" + source: hosted + version: "0.11.1" meta: dependency: transitive description: @@ -449,6 +462,11 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" source_gen: dependency: transitive description: @@ -497,11 +515,12 @@ packages: source: path version: "1.5.0" stac_logger: - dependency: "direct overridden" + dependency: transitive description: - path: "../stac_logger" - relative: true - source: path + name: stac_logger + sha256: bc3c1cc486d59d2378c1e18bfd9bfa078be564b58d4ae2b3898633c05a02df26 + url: "https://pub.dev" + source: hosted version: "1.1.0" stack_trace: dependency: transitive @@ -583,6 +602,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.4.0" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + url: "https://pub.dev" + source: hosted + version: "2.2.0" vm_service: dependency: transitive description: @@ -649,3 +676,4 @@ packages: version: "3.1.3" sdks: dart: ">=3.10.0 <4.0.0" + flutter: ">=1.17.0" diff --git a/packages/stac_cli/test/commands/cli_commands_test.dart b/packages/stac_cli/test/commands/cli_commands_test.dart new file mode 100644 index 00000000..99b50d2c --- /dev/null +++ b/packages/stac_cli/test/commands/cli_commands_test.dart @@ -0,0 +1,53 @@ +import 'package:test/test.dart'; +import 'package:args/command_runner.dart'; +import 'package:stac_cli/src/commands/build_command.dart'; +import 'package:stac_cli/src/commands/init_command.dart'; +import 'package:stac_cli/src/commands/deploy_command.dart'; +import 'package:stac_cli/src/config/env.dart'; + +/// Test suite for verifying core Stac CLI commands. +void main() { + group('CLI Commands', () { + late CommandRunner runner; + + setUp(() { + // Initialize environment with mock values to satisfy required checks in services. + // This allows testing command configuration without needing real API keys. + configureEnvironment({ + 'STAC_BASE_API_URL': 'https://api.test.stac.dev', + 'STAC_GOOGLE_CLIENT_ID': 'test-client-id', + 'STAC_FIREBASE_API_KEY': 'test-api-key', + }); + + runner = CommandRunner('stac', 'Stac CLI test runner'); + runner.addCommand(BuildCommand()); + runner.addCommand(InitCommand()); + runner.addCommand(DeployCommand()); + }); + + tearDown(() { + configureEnvironment({}); + }); + + test('build command has correct name and description', () { + final command = runner.commands['build']; + expect(command, isNotNull, reason: 'BuildCommand should be registered'); + expect(command!.name, equals('build')); + expect(command.description, isNotEmpty); + }); + + test('init command has correct name and description', () { + final command = runner.commands['init']; + expect(command, isNotNull, reason: 'InitCommand should be registered'); + expect(command!.name, equals('init')); + expect(command.description, isNotEmpty); + }); + + test('deploy command has correct name and description', () { + final command = runner.commands['deploy']; + expect(command, isNotNull, reason: 'DeployCommand should be registered'); + expect(command!.name, equals('deploy')); + expect(command.description, isNotEmpty); + }); + }); +} diff --git a/packages/stac_cli/test/utils/file_utils_test.dart b/packages/stac_cli/test/utils/file_utils_test.dart new file mode 100644 index 00000000..b7d005e2 --- /dev/null +++ b/packages/stac_cli/test/utils/file_utils_test.dart @@ -0,0 +1,70 @@ +import 'dart:io'; +import 'package:test/test.dart'; +import 'package:stac_cli/src/utils/file_utils.dart'; +import 'package:path/path.dart' as path; + +/// Test suite for Stac CLI file utility operations. +void main() { + group('FileUtils', () { + // Basic verification of environment-dependent directory getters. + test('homeDirectory returns a non-empty string on this OS and points to an existing directory', () async { + final home = FileUtils.homeDirectory; + expect(home, isNotEmpty); + final dir = Directory(home); + expect(await dir.exists(), isTrue, reason: 'Home directory must exist'); + final stat = await dir.stat(); + expect(stat.type, equals(FileSystemEntityType.directory), reason: 'Home directory path must be a directory'); + }); + + test('configDirectory path is generated and points to a valid directory', () async { + final config = FileUtils.configDirectory; + expect(config, isNotEmpty); + + final dir = Directory(config); + final originallyExisted = await dir.exists(); + + // Ensure config directory exists (creating it if necessary) + await FileUtils.ensureConfigDirectory(); + + expect(await dir.exists(), isTrue, reason: 'Config directory must exist after ensuring'); + final stat = await dir.stat(); + expect(stat.type, equals(FileSystemEntityType.directory), reason: 'Config directory path must be a directory'); + + // Clean up the created config directory if it didn't exist before the test + if (!originallyExisted && await dir.exists()) { + try { + await dir.delete(recursive: true); + } catch (_) {} + } + }); + + // Integrated test for file system operations using a temporary directory. + test('integrated file operations: create, read, and delete', () async { + // Setup a clean temporary sandbox for this test. + final tempDir = Directory.systemTemp.createTempSync('stac_cli_test'); + final filePath = path.join(tempDir.path, 'test_file.txt'); + + try { + // 1. Initial State: file should not exist. + expect(await FileUtils.fileExists(filePath), isFalse); + + // 2. Write Operation: create file with content. + await FileUtils.writeFile(filePath, 'hello world'); + expect(await FileUtils.fileExists(filePath), isTrue); + + // 3. Read Operation: verify content matches. + final content = await FileUtils.readFile(filePath); + expect(content, equals('hello world')); + + // 4. Delete Operation: cleanup file. + await FileUtils.deleteFile(filePath); + expect(await FileUtils.fileExists(filePath), isFalse); + } finally { + // Always cleanup the temporary directory logic even if tests fail. + if (tempDir.existsSync()) { + tempDir.deleteSync(recursive: true); + } + } + }); + }); +}