Skip to content

Commit

Permalink
Merge pull request #160 from devmil/chore/add_integration_test_for_re…
Browse files Browse the repository at this point in the history
…lative_path_issue

chore: adds an integration test for the recent relative path issue
  • Loading branch information
devmil authored Sep 27, 2023
2 parents b4c1d34 + 20047d0 commit 147f657
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/integration_tests/cli/extract_command_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'dart:convert';
import 'dart:io';

import 'package:args/command_runner.dart';
import 'package:dart_apitool/api_tool_cli.dart';
import 'package:test/test.dart';
Expand Down Expand Up @@ -34,6 +37,44 @@ void main() {
timeout: integrationTestTimeout,
);

test(
'packages with path dependencies don\'t yield unresolvable types',
() async {
final tempDir = await Directory.systemTemp.createTemp();
final tempFilePath = path.join(tempDir.path, 'extract_paths_test.json');
final exitCode = await runner.run([
'extract',
'--input',
path.join(
'test',
'test_packages',
'path_references',
'cluster_a',
'package_a',
),
'--output',
tempFilePath,
]);
expect(exitCode, 0);

final jsonReportFile = File(tempFilePath);
expect(await jsonReportFile.exists(), isTrue);

final jsonReport = jsonDecode(await jsonReportFile.readAsString());
await tempDir.delete(recursive: true);

// check if the ClassB field in ClassA has resolved its type
final interfaceDeclarations =
jsonReport['packageApi']['interfaceDeclarations'] as List;
final classADeclaration =
interfaceDeclarations.singleWhere((id) => id['name'] == 'ClassA');
final classBField = (classADeclaration['fieldDeclarations'] as List)
.singleWhere((fd) => fd['name'] == 'classB');
expect(classBField['typeName'], 'ClassB');
},
timeout: integrationTestTimeout,
);

test(
'Can handle pub ref',
() async {
Expand Down

0 comments on commit 147f657

Please sign in to comment.