Skip to content

Commit

Permalink
test: add test for loading node-workspace plugin always-link-local op…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
chingor13 committed Nov 10, 2023
1 parent 0e2305b commit 1fd157f
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/plugins/node-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ interface NodeWorkspaceOptions extends WorkspacePluginOptions {
* into a single node package.
*/
export class NodeWorkspace extends WorkspacePlugin<Package> {
private alwaysLinkLocal: boolean;
readonly alwaysLinkLocal: boolean;
private packageGraph?: PackageGraph;
constructor(
github: GitHub,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"release-type": "node",
"always-link-local": false,
"plugins": [
{
"type": "node-workspace"
}
],
"packages": {
"pkg1": {
"component": "pkg1"
},
"pkg2": {
"component": "pkg2"
},
"pkg3": {
"component": "pkg3"
}
}
}
20 changes: 20 additions & 0 deletions test/fixtures/manifest/config/node-workspace-plugins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"release-type": "node",
"plugins": [
{
"type": "node-workspace",
"alwaysLinkLocal": false
}
],
"packages": {
"pkg1": {
"component": "pkg1"
},
"pkg2": {
"component": "pkg2"
},
"pkg3": {
"component": "pkg3"
}
}
}
58 changes: 58 additions & 0 deletions test/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,64 @@ describe('Manifest', () => {
const plugin = manifest.plugins[0] as MavenWorkspace;
expect(plugin.considerAllArtifacts).to.be.true;
});
it('should build node-workspace from manifest', async () => {
const getFileContentsStub = sandbox.stub(
github,
'getFileContentsOnBranch'
);
getFileContentsStub
.withArgs('release-please-config.json', 'main')
.resolves(
buildGitHubFileContent(
fixturesPath,
'manifest/config/node-workspace-plugins.json'
)
)
.withArgs('.release-please-manifest.json', 'main')
.resolves(
buildGitHubFileContent(
fixturesPath,
'manifest/versions/versions.json'
)
);
const manifest = await Manifest.fromManifest(
github,
github.repository.defaultBranch
);
expect(manifest.plugins).lengthOf(1);
expect(manifest.plugins[0]).instanceOf(NodeWorkspace);
const plugin = manifest.plugins[0] as NodeWorkspace;
expect(plugin.alwaysLinkLocal).to.be.false;
});
it('should build node-workspace from manifest with deprecated always-link-local', async () => {
const getFileContentsStub = sandbox.stub(
github,
'getFileContentsOnBranch'
);
getFileContentsStub
.withArgs('release-please-config.json', 'main')
.resolves(
buildGitHubFileContent(
fixturesPath,
'manifest/config/node-workspace-plugins-deprecated.json'
)
)
.withArgs('.release-please-manifest.json', 'main')
.resolves(
buildGitHubFileContent(
fixturesPath,
'manifest/versions/versions.json'
)
);
const manifest = await Manifest.fromManifest(
github,
github.repository.defaultBranch
);
expect(manifest.plugins).lengthOf(1);
expect(manifest.plugins[0]).instanceOf(NodeWorkspace);
const plugin = manifest.plugins[0] as NodeWorkspace;
expect(plugin.alwaysLinkLocal).to.be.false;
});
it('should configure search depth from manifest', async () => {
const getFileContentsStub = sandbox.stub(
github,
Expand Down

0 comments on commit 1fd157f

Please sign in to comment.