mirror of
https://gitee.com/dcren/initializr.git
synced 2025-04-05 17:38:06 +08:00
Add a gradle assertion for build properties
See gh-781
This commit is contained in:
parent
3982ceceeb
commit
3ceb608f87
@ -718,8 +718,7 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
||||
request.getBuildProperties().getMaven().put("ignore.property", () -> "yes");
|
||||
|
||||
generateGradleBuild(request).contains("name = 'test'")
|
||||
.contains("set('foo.version', '1.2.3')")
|
||||
.contains("set('internalVersion', '4.5.6')")
|
||||
.hasBuildProperties("foo.version=1.2.3", "internalVersion=4.5.6")
|
||||
.doesNotContain("ignore.property");
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,18 @@ public class GradleBuildAssert {
|
||||
return contains("maven { url \"" + url + "\" }");
|
||||
}
|
||||
|
||||
public GradleBuildAssert hasBuildProperties(String... pairs) {
|
||||
StringBuilder builder = new StringBuilder("ext {\n");
|
||||
for (String pair : pairs) {
|
||||
int index = pair.indexOf('=');
|
||||
String name = (index > 0) ? pair.substring(0, index) : pair;
|
||||
String value = (index > 0) ? pair.substring(index + 1) : "";
|
||||
builder.append("\tset('" + name + "', '" + value + "')\n");
|
||||
}
|
||||
builder.append("}");
|
||||
return contains(builder.toString());
|
||||
}
|
||||
|
||||
public GradleBuildAssert contains(String expression) {
|
||||
assertThat(this.content).contains(expression);
|
||||
return this;
|
||||
|
Loading…
Reference in New Issue
Block a user