diff --git a/test/workspace_test.dart b/test/workspace_test.dart index df00a0f02b..46d2359143 100644 --- a/test/workspace_test.dart +++ b/test/workspace_test.dart @@ -7,10 +7,12 @@ import 'dart:io'; import 'package:path/path.dart' as p; import 'package:pub/src/exit_codes.dart'; +import 'package:shelf/shelf.dart' as shelf; import 'package:test/test.dart'; import 'package:yaml/yaml.dart'; import 'descriptor.dart'; +import 'lish/utils.dart'; import 'test_pub.dart'; void main() { @@ -1294,6 +1296,58 @@ Consider removing one of the overrides.''', output: contains('! foo 1.0.1 from path ..${s}foo (overridden)'), ); }); + + test('Can publish from workspace', () async { + final server = await servePackages(); + await credentialsFile(server, 'access-token').create(); + server.expect('GET', '/create', (request) { + return shelf.Response.ok( + jsonEncode({ + 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}, + }), + ); + }); + await dir('workspace', [ + libPubspec( + 'workspace', + '1.2.3', + extras: { + 'workspace': [appPath], + }, + sdk: '^3.5.0', + ), + validPackage( + pubspecExtras: { + 'environment': {'sdk': '^3.5.0'}, + 'resolution': 'workspace', + }, + ), + ]).create(); + + await runPub( + args: ['publish', '--to-archive=archive.tar.gz'], + workingDirectory: p.join(sandbox, 'workspace', appPath), + environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'}, + output: contains(''' +├── CHANGELOG.md (<1 KB) +├── LICENSE (<1 KB) +├── README.md (<1 KB) +├── lib +│ └── test_pkg.dart (<1 KB) +└── pubspec.yaml (<1 KB) +'''), + ); + + final pub = await startPublish( + server, + workingDirectory: p.join(sandbox, 'workspace', appPath), + environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'}, + ); + + await confirmPublish(pub); + handleUploadForm(server); + handleUpload(server); + }); } final s = p.separator;