Resolves s4u/maven-settings-action#348, plugin repositories support

This commit is contained in:
Patrick Woodworth
2024-09-23 17:31:53 -07:00
committed by Slawomir Jaranowski
parent 06520eb502
commit 074e0bfd5e
8 changed files with 105 additions and 22 deletions

View File

@ -87,7 +87,7 @@ afterAll(() => {
}
try {
fs.rmdirSync(testHomePath);
fs.rmSync(testHomePath, { recursive: true });
} catch (error) {
}
});
@ -841,17 +841,60 @@ test('addCustomRepositories - one with snapshots one without', () => {
<id>repoId</id>
<name>repoName</name>
<url>url</url>
<snapshots><enabled>true</enabled></snapshots>
</repository> <repository>
<id>repoId2</id>
<url>url2</url>
</repository></repositories>
<pluginRepositories/>
</profile></profiles>`);
});
test('addCustomPluginRepositories - one with releases and snapshots one without', () => {
process.env['INPUT_PLUGINREPOSITORIES'] = `
[{"id":"repoId",
"name":"repoName",
"url":"url",
"releases":{"enabled":false},
"snapshots":{"enabled":true}
},{
"id":"repoId2",
"url":"url2"
}]`
const xml = stringAsXml('<profiles/>');
settings.fillRepositories(xml,'pluginRepositories');
const xmlStr = new XMLSerializer().serializeToString(xml);
expect(xmlStr).toBe(`<profiles>
<profile>
<id>_custom_repositories_</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories/>
<pluginRepositories> <pluginRepository>
<id>repoId</id>
<name>repoName</name>
<url>url</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository> <pluginRepository>
<id>repoId2</id>
<url>url2</url>
</pluginRepository></pluginRepositories>
</profile></profiles>`);
});
test('addCustomRepositories - fail if url is missing', () => {
process.env['INPUT_REPOSITORIES'] = '[{"id":"repoId","name":"repoName"}]'
@ -876,4 +919,4 @@ test('addCustomRepositories - fail if url is missing', () => {
expect.stringMatching(/::error::repositories must contain id and url/)
])
);
});
});