mirror of
https://github.com/floci-io/floci-cli.git
synced 2026-11-22 21:50:47 -05:00
chore: first commit
This commit is contained in:
69 files changed
+3697
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package io.floci.cli.unit;
|
||||
|
||||
import io.floci.cli.doctor.checks.DockerVersionCheck;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class DockerVersionCheckTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"24.0.7, true",
|
||||
"20.10.0, true",
|
||||
"20.10, true",
|
||||
"20.9.0, false",
|
||||
"19.03.0, false",
|
||||
"26.1.3, true"
|
||||
})
|
||||
void testVersionParsing(String version, boolean expected) {
|
||||
assertEquals(expected, DockerVersionCheck.meetsMinimum(version));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUnparseable() {
|
||||
assertTrue(DockerVersionCheck.meetsMinimum("dev"), "unparseable version should pass");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package io.floci.cli.unit;
|
||||
|
||||
import io.floci.cli.FlociCli;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import picocli.CommandLine;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class FlociCliParsingTest {
|
||||
|
||||
@Test
|
||||
void helpExitsZero() {
|
||||
int code = new CommandLine(new FlociCli()).execute("--help");
|
||||
assertEquals(0, code);
|
||||
}
|
||||
|
||||
@Test
|
||||
void versionFlag() {
|
||||
int code = new CommandLine(new FlociCli()).execute("--version");
|
||||
assertEquals(0, code);
|
||||
}
|
||||
|
||||
@Test
|
||||
void unknownCommandExitsNonZero() {
|
||||
int code = new CommandLine(new FlociCli()).execute("nonexistent-subcommand");
|
||||
assertNotEquals(0, code);
|
||||
}
|
||||
|
||||
@Test
|
||||
void subcommandHelpExitsZero() {
|
||||
int code = new CommandLine(new FlociCli()).execute("doctor", "--help");
|
||||
assertEquals(0, code);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package io.floci.cli.unit;
|
||||
|
||||
import io.floci.cli.doctor.checks.ImageVersionCheck;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class ImageVersionCheckTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"1.5.0, 1.5.0, true",
|
||||
"1.5.1, 1.5.0, true",
|
||||
"2.0.0, 1.5.0, true",
|
||||
"1.4.9, 1.5.0, false",
|
||||
"1.5.0-SNAPSHOT, 1.5.0, true"
|
||||
})
|
||||
void testSemVerComparison(String version, String minimum, boolean expected) {
|
||||
assertEquals(expected, ImageVersionCheck.meetsMinimum(version, minimum));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package io.floci.cli.unit;
|
||||
|
||||
import io.floci.cli.doctor.checks.PortAvailableCheck;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class PortAvailableCheckTest {
|
||||
|
||||
@Test
|
||||
void testPortExtraction() {
|
||||
assertEquals(4566, PortAvailableCheck.extractPort("http://localhost:4566"));
|
||||
assertEquals(8080, PortAvailableCheck.extractPort("http://localhost:8080"));
|
||||
assertEquals(4566, PortAvailableCheck.extractPort("invalid"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package io.floci.cli.unit;
|
||||
|
||||
import io.floci.cli.commands.WaitCommand;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class WaitCommandParseTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"30s, 30000",
|
||||
"2m, 120000",
|
||||
"1h, 3600000",
|
||||
"500ms, 500",
|
||||
"10, 10000"
|
||||
})
|
||||
void testDurationParsing(String input, long expectedMillis) {
|
||||
assertEquals(expectedMillis, WaitCommand.parseDuration(input.trim()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNullDuration() {
|
||||
assertEquals(30_000, WaitCommand.parseDuration(null));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user