mateclaw/mateclaw-server/src/test/java/vip/mate/wiki/service/WikiEmbeddingVersionCompareTest.java
matevip 0ffc224623 chore(test): backfill mateclaw-server/src/test/ that earlier PRIVATE_ITEMS pattern accidentally excluded
The PRIVATE_ITEMS list contained the bare 'test' entry, which rsync
interprets as 'any directory named test at any depth' — so it caught
the root-level /test/ scratch directory (intended) AND every src/test/
under each module (not intended).

Pattern is already anchored to /test (root-only). This commit rsyncs
the accumulated src/test/ tree forward so opensource has the unit tests
that have been written / updated against existing src/main/ code since
the pattern regression. Going forward each per-commit sync will carry
src/test/ files along with the main change.
2026-05-12 17:38:08 +08:00

41 lines
1.7 KiB
Java

package vip.mate.wiki.service;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Covers the comparison logic that drives the startup self-check for the
* embedding input version. Numeric "vN" tags should order naturally (v2 <
* v10), and the fallback to case-insensitive string compare should kick in
* for anything else without throwing.
*/
class WikiEmbeddingVersionCompareTest {
@Test
@DisplayName("compareInputVersions: numeric tags compare numerically (v2 < v10)")
void numericOrdering() {
assertThat(WikiEmbeddingService.compareInputVersions("v2", "v10")).isNegative();
assertThat(WikiEmbeddingService.compareInputVersions("v10", "v2")).isPositive();
assertThat(WikiEmbeddingService.compareInputVersions("v3", "v3")).isZero();
assertThat(WikiEmbeddingService.compareInputVersions("V1", "v1")).isZero();
}
@Test
@DisplayName("compareInputVersions: non-numeric tags fall back to string compare")
void stringFallback() {
assertThat(WikiEmbeddingService.compareInputVersions("alpha", "beta")).isNegative();
assertThat(WikiEmbeddingService.compareInputVersions("beta", "alpha")).isPositive();
assertThat(WikiEmbeddingService.compareInputVersions("preview", "preview")).isZero();
}
@Test
@DisplayName("compareInputVersions: mixed numeric / non-numeric does not throw")
void mixedTags() {
// We don't assert sign — only that the comparator stays total.
WikiEmbeddingService.compareInputVersions("v1", "alpha");
WikiEmbeddingService.compareInputVersions("alpha", "v1");
}
}