11package me .itzg .helpers .modrinth ;
22
33import static com .github .tomakehurst .wiremock .client .WireMock .*;
4+ import static java .util .Arrays .asList ;
5+ import static java .util .Collections .singletonList ;
46import static org .assertj .core .api .Assertions .assertThat ;
57import static org .junit .jupiter .params .provider .Arguments .argumentSet ;
68
79import com .github .stefanbirkner .systemlambda .SystemLambda ;
810import com .github .tomakehurst .wiremock .junit5 .WireMockRuntimeInfo ;
911import com .github .tomakehurst .wiremock .junit5 .WireMockTest ;
10- import java .util .Arrays ;
1112import java .util .List ;
1213import org .junit .jupiter .api .Test ;
1314import org .junit .jupiter .params .ParameterizedTest ;
@@ -36,27 +37,71 @@ void processGameVersions(List<List<String>> versions, String expected) {
3637 }
3738
3839 @ SuppressWarnings ("unused" ) // will be fixed https://youtrack.jetbrains.com/issue/IDEA-358214/Support-JUnit-5-FieldSource-annotation
39- static List <Arguments > processGameVersionsArgs = Arrays . asList (
40- argumentSet ("matches" , Arrays . asList (
41- Arrays . asList ("1.21.6" , "1.21.7" , "1.21.8" ),
42- Arrays . asList ("1.21.6" , "1.21.7" , "1.21.8" ),
43- Arrays . asList ("1.21.6" , "1.21.7" , "1.21.8" ),
44- Arrays . asList ("1.21.6" , "1.21.7" , "1.21.8" )
40+ static List <Arguments > processGameVersionsArgs = asList (
41+ argumentSet ("matches" , asList (
42+ asList ("1.21.6" , "1.21.7" , "1.21.8" ),
43+ asList ("1.21.6" , "1.21.7" , "1.21.8" ),
44+ asList ("1.21.6" , "1.21.7" , "1.21.8" ),
45+ asList ("1.21.6" , "1.21.7" , "1.21.8" )
4546 ), "1.21.8"
4647 ),
47- argumentSet ("justOneOff" , Arrays . asList (
48- Arrays . asList ("1.21.6" , "1.21.7" , "1.21.8" ),
49- Arrays . asList ("1.21.6" , "1.21.7" , "1.21.8" ),
50- Arrays . asList ("1.21.6" , "1.21.7" ),
51- Arrays . asList ("1.21.6" , "1.21.7" , "1.21.8" )
48+ argumentSet ("justOneOff" , asList (
49+ asList ("1.21.6" , "1.21.7" , "1.21.8" ),
50+ asList ("1.21.6" , "1.21.7" , "1.21.8" ),
51+ asList ("1.21.6" , "1.21.7" ),
52+ asList ("1.21.6" , "1.21.7" , "1.21.8" )
5253 ), "1.21.7"
5354 ),
54- argumentSet ("mismatch" , Arrays . asList (
55- Arrays . asList ("1.21.6" , "1.21.7" , "1.21.8" ),
56- Arrays . asList ("1.21.6" , "1.21.7" , "1.21.8" ),
57- Arrays . asList ("1.21.4" , "1.21.5" ),
58- Arrays . asList ("1.21.6" , "1.21.7" , "1.21.8" )
55+ argumentSet ("mismatch" , asList (
56+ asList ("1.21.6" , "1.21.7" , "1.21.8" ),
57+ asList ("1.21.6" , "1.21.7" , "1.21.8" ),
58+ asList ("1.21.4" , "1.21.5" ),
59+ asList ("1.21.6" , "1.21.7" , "1.21.8" )
5960 ), null
61+ ),
62+ argumentSet ("fabric-api + nucledoom" , asList (
63+ // part of fabric-api
64+ asList ("24w46a" ,
65+ "1.21.4-pre1" ,
66+ "1.21.4-pre2" ,
67+ "1.21.4-pre3" ,
68+ "1.21.4-rc3" ,
69+ "1.21.4" ,
70+ "25w02a" ,
71+ "25w03a" ,
72+ "25w04a" ,
73+ "25w05a" ,
74+ "25w06a" ,
75+ "25w07a" ,
76+ "25w08a" ,
77+ "25w09a" ,
78+ "25w09b" ,
79+ "25w10a" ,
80+ "1.21.5-pre1" ,
81+ "1.21.5-pre2" ,
82+ "1.21.5-pre3" ,
83+ "1.21.5-rc1" ,
84+ "1.21.5-rc2" ,
85+ "1.21.5" ,
86+ "25w14craftmine" ,
87+ "25w15a" ,
88+ "25w16a" ,
89+ "25w17a" ,
90+ "25w18a" ,
91+ "25w19a" ,
92+ "25w20a" ,
93+ "25w21a" ,
94+ "1.21.6-pre1" ,
95+ "1.21.6-pre3" ,
96+ "1.21.6" ,
97+ "1.21.7-rc1" ,
98+ "1.21.7" ,
99+ "1.21.8" ,
100+ "25w31a" ,
101+ "25w32a" ),
102+ // part of nucledoom
103+ singletonList ("1.21.4" )
104+ ), "1.21.4"
60105 )
61106 );
62107
@@ -79,6 +124,25 @@ void testCommand(WireMockRuntimeInfo wmInfo) throws Exception {
79124 assertThat (out ).isEqualToNormalizingNewlines ("1.21.7\n " );
80125 }
81126
127+ @ Test
128+ void testCommandFabric (WireMockRuntimeInfo wmInfo ) throws Exception {
129+
130+ stubGetProjects ("fabric-api" , "nucledoom" );
131+
132+ final String out = SystemLambda .tapSystemOut (() -> {
133+ final int exitCode = new CommandLine (new VersionFromModrinthProjectsCommand ())
134+ .execute (
135+ "--api-base-url" , wmInfo .getHttpBaseUrl (),
136+ "--projects" , "fabric-api, nucledoom"
137+ );
138+
139+ assertThat (exitCode )
140+ .isEqualTo (ExitCode .OK );
141+ });
142+
143+ assertThat (out ).isEqualToNormalizingNewlines ("1.21.4\n " );
144+ }
145+
82146 @ Test
83147 void testCommandWithProjectQualifiers (WireMockRuntimeInfo wmInfo ) throws Exception {
84148
0 commit comments