forked from halo-dev/halo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix startup exception and theme imports in dev environment (halo…
…-dev#916) * Log error instead of throwing while starting halo * Provide unknown version support * Fix code format
- Loading branch information
Showing
4 changed files
with
70 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,45 @@ | ||
package run.halo.app.utils; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.apache.commons.lang3.RandomStringUtils; | ||
import org.junit.jupiter.api.Test; | ||
import run.halo.app.model.support.HaloConst; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
/** | ||
* @author ryanwang | ||
* @date 2020-02-03 | ||
*/ | ||
public class VersionUtilTest { | ||
class VersionUtilTest { | ||
|
||
@Test | ||
public void compareVersion() { | ||
Assert.assertTrue(VersionUtil.compareVersion("1.2.0", "1.1.1")); | ||
|
||
Assert.assertTrue(VersionUtil.compareVersion("1.2.1", "1.2.0")); | ||
|
||
Assert.assertTrue(VersionUtil.compareVersion("1.2.0", "1.1.1.0")); | ||
|
||
Assert.assertTrue(VersionUtil.compareVersion("1.2.0", "0.4.4")); | ||
void compareVersion() { | ||
assertTrue(VersionUtil.compareVersion("1.2.0", "1.1.1")); | ||
assertTrue(VersionUtil.compareVersion("1.2.1", "1.2.0")); | ||
assertTrue(VersionUtil.compareVersion("1.2.0", "1.1.1.0")); | ||
assertTrue(VersionUtil.compareVersion("1.2.0", "0.4.4")); | ||
assertFalse(VersionUtil.compareVersion("1.1.1", "1.2.0")); | ||
assertFalse(VersionUtil.compareVersion("0.0.1", "1.2.0")); | ||
} | ||
|
||
Assert.assertFalse(VersionUtil.compareVersion("1.1.1", "1.2.0")); | ||
@Test | ||
void unknownVersionCompareTest() { | ||
// build a random version | ||
String randomVersion = String.join(".", | ||
RandomStringUtils.randomNumeric(1), | ||
RandomStringUtils.randomNumeric(2), | ||
RandomStringUtils.randomNumeric(3)); | ||
VersionUtil.compareVersion(HaloConst.UNKNOWN_VERSION, randomVersion); | ||
} | ||
|
||
Assert.assertFalse(VersionUtil.compareVersion("0.0.1", "1.2.0")); | ||
@Test | ||
void unknownOrEmptyCanonicalVersionTest() { | ||
assertThrows(IllegalArgumentException.class, () -> VersionUtil.getCanonicalVersion(null)); | ||
int[] version = VersionUtil.getCanonicalVersion(HaloConst.UNKNOWN_VERSION); | ||
assertNotNull(version); | ||
assertEquals(4, version.length); | ||
for (int v : version) { | ||
assertEquals(Integer.MAX_VALUE, v); | ||
} | ||
} | ||
} |