Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
add unit test for updatePolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
zteater committed Oct 1, 2021
1 parent 3f314ea commit 98d6a3a
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/js/resources/when-repositories-update-policy.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">

<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>

<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>foo</id>
<name>foo</name>
<url>http://foo.bar</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories/>
</profile>
</profiles>

<servers/>

<mirrors/>

<pluginGroups/>

<proxies/>

</settings>
19 changes: 19 additions & 0 deletions test/js/update-repositories.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,24 @@ describe('validate repositories', function () {
});
});

describe('when configuring updatePolicy on repositories', function () {
it('<repositories><releases> should be appended with <updatePolicy>', function () {
// given input
process.env['INPUT_REPOSITORIES'] = '[{ "id": "foo", "name": "foo", "url": "http://foo.bar", "releases": { "enabled": "true", "updatePolicy": "always" }, "snapshots": { "enabled": "true" } }]';

// when
var actualXml = settings.getSettingsTemplate();
settings.update(actualXml);
var actual = settings.formatSettings(actualXml);

// then
var expectedXml = settings.getTemplate('../test/js/resources/', 'when-repositories-update-policy.xml');
expected = settings.formatSettings(expectedXml);
assert.equal(actual, expected);

process.env['INPUT_REPOSITORIES'] = '';
});
});

});

0 comments on commit 98d6a3a

Please sign in to comment.