Update to new maven and add tests (#2)

Use maven central

Signed-off-by: Etzelia <etzelia@hotmail.com>

Update to new maven and add tests

Signed-off-by: Etzelia <etzelia@hotmail.com>

Reviewed-on: https://git.birbmc.com/BirbMC/javacord/pulls/2
Co-Authored-By: Etzelia <etzelia@hotmail.com>
Co-Committed-By: Etzelia <etzelia@hotmail.com>
main
Etzelia 2021-06-11 02:50:39 +00:00
parent 73034785da
commit 51bdafd58f
11 changed files with 95 additions and 33 deletions

View File

@ -12,6 +12,7 @@ steps:
image: gradle:6.6
commands:
- gradle build
- gradle test
---
kind: pipeline

View File

@ -4,8 +4,8 @@ A small, no-dependency Discord utility library. Currently used for webhooks/embe
## Releases
[Reposilite](https://repo.etztech.xyz/releases/xyz/etztech/javacord)
[Reposilite](https://mvn.birbmc.com/releases/xyz/etztech/javacord)
## License
[MIT](LICENSE``)
[MIT](LICENSE)

View File

@ -7,6 +7,19 @@ group = 'xyz.etztech'
version = '0.2.2'
sourceCompatibility = '8'
repositories {
mavenCentral()
}
test {
useJUnitPlatform()
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.6.2")
}
publishing {
publications {
maven(MavenPublication) {
@ -15,10 +28,10 @@ publishing {
}
repositories {
maven {
name = "etztech"
url = "https://repo.etztech.xyz/releases"
name = "birbmc"
url = "https://mvn.birbmc.com/releases"
credentials {
username = "etzelia"
username = "admin"
password = System.getenv("MAVEN_PASSWORD")
}
}

View File

@ -0,0 +1,23 @@
package xyz.etztech;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class JavacordTest {
@Test
void TestEscapeFormat() {
String raw = "*Test* **Test** _Test_ __Test__ ~Test~ ~~Test~~ |Test| ||Test||";
String escaped = Javacord.escapeFormat(raw);
String expected = "\\\\*Test\\\\* \\\\*\\\\*Test\\\\*\\\\* \\\\_Test\\\\_ \\\\_\\\\_Test\\\\_\\\\_ \\\\~Test\\\\~ \\\\~\\\\~Test\\\\~\\\\~ \\\\|Test\\\\| \\\\|\\\\|Test\\\\|\\\\|";
Assertions.assertEquals(expected, escaped);
}
@Test
void TestEscapeQuote() {
String raw = "\"Test\"";
String escaped = Javacord.escapeQuote(raw);
String expected = "\\\"Test\\\"";
Assertions.assertEquals(expected, escaped);
}
}

View File

@ -0,0 +1,25 @@
package xyz.etztech.embed;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
public class EmbedTest {
@Test
void TestEmbed() {
Embed embed = new Embed()
.color(0x151515)
.author(new Author("Etzelia", "https://etzel.ia", "" ,""))
.title("Test \"Title\"")
.description("Test Description")
.fields(Arrays.asList(
new Field("Field1", "foo"),
new Field("Field2", "bar"),
new Field("Field3", "baz", true)
));
String expected = "{\"embed\":{\"title\":\"Test \\\"Title\\\"\",\"description\":\"Test Description\",\"color\":\"1381653\",\"author\":{\"name\":\"Etzelia\",\"url\":\"https://etzel.ia\"},\"fields\":[{\"name\":\"Field1\",\"value\":\"foo\"},{\"name\":\"Field2\",\"value\":\"bar\"},{\"name\":\"Field3\",\"value\":\"baz\",\"inline\":true}]}}";
Assertions.assertEquals(expected, embed.toString());
}
}