Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: adds an integration test for the recent relative path issue #160

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading