Skip to content

Commit

Permalink
RegistryServiceTest : remove unused variable hasImage and dockerFileU…
Browse files Browse the repository at this point in the history
…tilMockedStatic

Signed-off-by: M. <[email protected]>
  • Loading branch information
mdxabu authored and rohanKanojia committed Mar 16, 2024
1 parent 556a8a6 commit fc53963
Showing 1 changed file with 1 addition and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import io.fabric8.maven.docker.config.ImagePullPolicy;
import io.fabric8.maven.docker.util.AuthConfigFactory;
import io.fabric8.maven.docker.util.AutoPullMode;
import io.fabric8.maven.docker.util.DockerFileUtil;
import io.fabric8.maven.docker.util.ImageName;
import io.fabric8.maven.docker.util.Logger;
import io.fabric8.maven.docker.util.ProjectPaths;
Expand All @@ -25,7 +24,6 @@
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;

Expand Down Expand Up @@ -57,9 +55,8 @@ class RegistryServiceTest {
private TestCacheStore cacheStore;
private AutoPullMode autoPullMode;
private RegistryService registryService;
private boolean hasImage;
private Map<String, String> authConfig;
private MockedStatic<DockerFileUtil> dockerFileUtilMockedStatic;


@TempDir
private File projectBaseDir;
Expand Down Expand Up @@ -96,7 +93,6 @@ void setup() {
imageName = null;
imagePullPolicy = null;
autoPullMode = null;
hasImage = false;
registry = null;
imageConfiguration = null;
}
Expand All @@ -107,8 +103,6 @@ void pullImagePullPolicyAlways(boolean hasImage) throws Exception {
givenAnImage();
givenAnImageConfiguration("myregistry.com/user/app:1.0.1");
givenImagePullPolicy(ImagePullPolicy.Always);
givenHasImage(hasImage);

checkPulledButNotTagged();
}

Expand All @@ -118,8 +112,6 @@ void pullImageAutopullAlways(boolean hasImage) throws Exception {
givenAnImage();
givenAnImageConfiguration("myregistry.com/user/app:1.0.1");
givenAutoPullMode(AutoPullMode.ALWAYS);
givenHasImage(hasImage);

checkPulledButNotTagged();
}

Expand All @@ -136,7 +128,6 @@ private void checkPulledButNotTagged() throws DockerAccessException {
void pullImageAlwaysWhenPreviouslyPulled() throws Exception {
givenAnImage();
givenAnImageConfiguration("myregistry.com/user/app:1.0.1");
givenHasImage(false);
givenPreviousPulled(true);
givenImagePullPolicy(ImagePullPolicy.Always);

Expand Down Expand Up @@ -167,7 +158,6 @@ void alreadyPulled() throws DockerAccessException {
@Test
void policyNeverWithImageAvailable() throws DockerAccessException {
givenAnImage();
givenHasImage(true);
givenPreviousPulled(false);
givenImagePullPolicy(ImagePullPolicy.Never);

Expand All @@ -181,7 +171,6 @@ void policyNeverWithImageAvailable() throws DockerAccessException {
@Test
void policyNeverWithImageNotAvailable() throws DockerAccessException {
givenAnImage();
givenHasImage(false);
givenAnImageConfiguration("myregistry.com/user/app:1.0.1");
givenPreviousPulled(false);
givenImagePullPolicy(ImagePullPolicy.Never);
Expand All @@ -202,13 +191,10 @@ private void thenExceptionThrown() {
void pullWithCustomRegistry() throws DockerAccessException {
givenAnImageConfiguration("myregistry.com/user/app:1.0.1");
givenAnImage("myregistry.com/user/test:1.0.1");
givenHasImage(false);
givenPreviousPulled(false);
givenRegistry("anotherRegistry.com");
givenImagePullPolicy(ImagePullPolicy.IfNotPresent);

whenAutoPullImage();

thenImageHasBeenPulledWithRegistry("myregistry.com");
thenImageHasNotBeenTagged();
thenNoExceptionThrown();
Expand All @@ -223,7 +209,6 @@ void pullImageWithPolicy_pullPolicyAlwaysAndBuildConfiguration_shouldPull() thro
.name("myregistry.com/user/app:1.0.1")
.buildConfig(buildImageConfiguration).build();
givenAnImage("myregistry.com/user/test:1.0.1");
givenHasImage(false);
givenPreviousPulled(false);
givenRegistry("anotherRegistry.com");
givenImagePullPolicy(ImagePullPolicy.Always);
Expand All @@ -248,7 +233,6 @@ void pullImageWithPolicy_pullPolicyAlwaysAndBuildConfiguration_shouldPull() thro
void tagForCustomRegistry() throws DockerAccessException {
givenAnImageConfiguration("myregistry.com/user/app:1.0.1");
givenAnImage("user/test:1.0.1");
givenHasImage(false);
givenPreviousPulled(false);
givenRegistry("anotherRegistry.com");
givenImagePullPolicy(ImagePullPolicy.IfNotPresent);
Expand Down Expand Up @@ -533,9 +517,6 @@ private void givenAutoPullMode(AutoPullMode autoPullMode) {
this.autoPullMode = autoPullMode;
}

private void givenHasImage(boolean hasImage) {
this.hasImage = hasImage;
}

private void givenPreviousPulled(boolean pulled) {
this.cacheStore.put("dummyKey", pulled ? "{ '" + imageName + "': true}" : null);
Expand Down

0 comments on commit fc53963

Please sign in to comment.