55import static org .junit .jupiter .api .Assertions .assertNotNull ;
66import static org .junit .jupiter .api .Assertions .assertTrue ;
77
8+ import com .github .sparsick .testcontainers .gitserver .GitServerVersions ;
9+ import com .github .sparsick .testcontainers .gitserver .http .GitHttpServerContainer ;
810import com .github .tomakehurst .wiremock .client .WireMock ;
911import com .github .tomakehurst .wiremock .junit5 .WireMockRuntimeInfo ;
1012import com .github .tomakehurst .wiremock .junit5 .WireMockTest ;
2628import org .junit .jupiter .api .io .TempDir ;
2729import org .slf4j .Logger ;
2830import org .slf4j .LoggerFactory ;
31+ import org .testcontainers .junit .jupiter .Container ;
32+ import org .testcontainers .junit .jupiter .Testcontainers ;
2933
3034/**
3135 * Integration test for the command line interface
3236 */
3337@ WireMockTest
38+ @ Testcontainers (disabledWithoutDocker = true )
3439public class CommandLineITCase {
3540
41+ @ Container
42+ private GitHttpServerContainer gitRemote = new GitHttpServerContainer (GitServerVersions .V2_45 .getDockerImageName ());
43+
3644 /**
3745 * Logger
3846 */
@@ -127,7 +135,7 @@ public void testListRecipes() throws Exception {
127135 }
128136
129137 @ Test
130- public void testNotBuildMetadataForDeprecatedPlugin (WireMockRuntimeInfo wmRuntimeInfo ) throws Exception {
138+ public void testBuildMetadata (WireMockRuntimeInfo wmRuntimeInfo ) throws Exception {
131139 LOG .info ("Running testBuildMetadataForDeprecatedPlugin" );
132140
133141 PluginStatsApiResponse pluginStatsApiResponse = new PluginStatsApiResponse (Map .of ("a-fake-plugin" , 1 ));
@@ -137,7 +145,7 @@ public void testNotBuildMetadataForDeprecatedPlugin(WireMockRuntimeInfo wmRuntim
137145 new UpdateCenterData .UpdateCenterPlugin (
138146 "a-fake-plugin" ,
139147 "1" ,
140- "git@github.com:jenkinsci/a-fake-plugin.git" ,
148+ gitRemote . getGitRepoURIAsHttp (). toString () ,
141149 "main" ,
142150 "io.jenkins.plugins:a-fake" ,
143151 null )),
@@ -153,6 +161,9 @@ public void testNotBuildMetadataForDeprecatedPlugin(WireMockRuntimeInfo wmRuntim
153161 WireMock wireMock = wmRuntimeInfo .getWireMock ();
154162 wireMock .register (WireMock .get (WireMock .urlEqualTo ("/api/user" ))
155163 .willReturn (WireMock .jsonResponse (USER_API_RESPONSE , 200 )));
164+ wireMock .register (WireMock .get (WireMock .urlEqualTo ("/api/repos/jenkinsci/testRepo" ))
165+ .willReturn (WireMock .jsonResponse (
166+ new RepoApiResponse (gitRemote .getGitRepoURIAsHttp ().toString ()), 200 )));
156167 wireMock .register (WireMock .get (WireMock .urlEqualTo ("/update-center.json" ))
157168 .willReturn (WireMock .jsonResponse (updateCenterApiResponse , 200 )));
158169 wireMock .register (WireMock .get (WireMock .urlEqualTo ("/plugin-versions.json" ))
@@ -255,6 +266,8 @@ private InvocationRequest buildRequest(String args) {
255266 */
256267 private record UserApiResponse (String login , String type ) {}
257268
269+ private record RepoApiResponse (String clone_url ) {}
270+
258271 private static final UserApiResponse USER_API_RESPONSE = new UserApiResponse ("fake-owner" , "User" );
259272
260273 private record PluginStatsApiResponse (Map <String , Integer > plugins ) {}
0 commit comments