Skip to content
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
54 changes: 54 additions & 0 deletions test/workspace_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;