Skip to content

Commit a6f5d26

Browse files
committed
ore: Add in basic test coverage
1 parent f3d58bd commit a6f5d26

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed

ore/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ dependencies {
1111
implementation(localGroovy())
1212
implementation(libs.gson)
1313
implementation(libs.apacheHttp.client)
14+
15+
runtimeOnly(project(":spongegradle-plugin-development")) // for pluginUnderTestMetadata
1416
}
1517

1618
sourceSets.main {
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* This file is part of spongegradle-ore, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.gradle.ore;
26+
27+
import net.kyori.mammoth.test.TestContext;
28+
import org.junit.jupiter.api.BeforeEach;
29+
import org.junit.jupiter.api.DisplayNameGeneration;
30+
import org.junit.jupiter.api.TestInfo;
31+
import org.spongepowered.gradle.build.FunctionalTestDisplayNameGenerator;
32+
import org.spongepowered.gradle.build.SpongeGradleFunctionalTest;
33+
34+
import java.io.IOException;
35+
36+
// Perform limited testing of the ore deployment plugin -- only things that can be performed without API requests
37+
// This is usually just configuration
38+
@DisplayNameGeneration(FunctionalTestDisplayNameGenerator.class)
39+
public class OreDeploymentFunctionalTest {
40+
41+
@BeforeEach
42+
void doFirst(final TestInfo info, final TestContext ctx) throws IOException {
43+
ctx.writeText("settings.gradle", "rootProject.name = \"" + info.getDisplayName() + "\"\n");
44+
}
45+
46+
@SpongeGradleFunctionalTest
47+
void testApplication(final TestContext ctx) throws IOException {
48+
ctx.copyInput("build.gradle");
49+
ctx.build("help");
50+
}
51+
52+
@SpongeGradleFunctionalTest
53+
void testPluginPlugin(final TestContext ctx) throws IOException {
54+
ctx.copyInput("build.gradle");
55+
ctx.build("help");
56+
}
57+
58+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
plugins {
2+
id 'java'
3+
id 'org.spongepowered.gradle.ore'
4+
}
5+
6+
oreDeployment.defaultPublication {
7+
projectId = "test"
8+
channel = "Release"
9+
publishArtifacts.from(tasks.named('jar').map { it.outputs })
10+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import org.spongepowered.gradle.plugin.config.PluginLoaders
2+
import org.spongepowered.plugin.metadata.model.PluginDependency
3+
4+
plugins {
5+
id 'java-library'
6+
id 'org.spongepowered.gradle.plugin'
7+
id 'org.spongepowered.gradle.ore'
8+
}
9+
10+
sponge {
11+
apiVersion("8.0.0")
12+
loader {
13+
name(PluginLoaders.JAVA_PLAIN)
14+
version("1.0")
15+
}
16+
license("CHANGEME")
17+
plugin("example") {
18+
displayName("Example")
19+
version("0.1")
20+
entrypoint("org.spongepowered.example.Example")
21+
description("Just testing things...")
22+
links {
23+
homepage("https://spongepowered.org")
24+
source("https://spongepowered.org/source")
25+
issues("https://spongepowered.org/issues")
26+
}
27+
contributor("Spongie") {
28+
description("Lead Developer")
29+
}
30+
dependency("spongeapi") {
31+
loadOrder(PluginDependency.LoadOrder.AFTER)
32+
optional(false)
33+
}
34+
}
35+
}
36+
37+
assert 'default' in oreDeployment.publications().names // created by SG injection

0 commit comments

Comments
 (0)