From c4398f19a957f830885c2db58799893019fec80b Mon Sep 17 00:00:00 2001 From: Sigurd Meldgaard Date: Fri, 24 May 2024 13:02:55 +0000 Subject: [PATCH 1/2] Test that a workspace package can be published --- test/workspace_test.dart | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/test/workspace_test.dart b/test/workspace_test.dart index df00a0f02b..6de1ae5dd8 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,44 @@ 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(); + + 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; From 7663e85e99027a93201fb311943f38b23fff537e Mon Sep 17 00:00:00 2001 From: Sigurd Meldgaard Date: Fri, 24 May 2024 13:06:49 +0000 Subject: [PATCH 2/2] Validate included files --- test/workspace_test.dart | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/workspace_test.dart b/test/workspace_test.dart index 6de1ae5dd8..46d2359143 100644 --- a/test/workspace_test.dart +++ b/test/workspace_test.dart @@ -1324,6 +1324,20 @@ Consider removing one of the overrides.''', ), ]).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),