-
Notifications
You must be signed in to change notification settings - Fork 995
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix stagingArtifactRegistry support raw us.gcr.io artifact registry (#…
- Loading branch information
Showing
2 changed files
with
82 additions
and
1 deletion.
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
81 changes: 81 additions & 0 deletions
81
...n-plugin/src/test/java/com/google/cloud/teleport/plugin/maven/TemplatesStageMojoTest.java
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (C) 2025 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.google.cloud.teleport.plugin.maven; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import com.google.common.base.Strings; | ||
import com.google.common.collect.ImmutableMap; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
@RunWith(JUnit4.class) | ||
public class TemplatesStageMojoTest { | ||
@Test | ||
public void testGenerateFlexTemplateImagePath() { | ||
String containerName = "name"; | ||
String projectId = "some-project"; | ||
String stagePrefix = "some-prefix"; | ||
ImmutableMap<String, String> testCases = | ||
ImmutableMap.<String, String>builder() | ||
.put("", "gcr.io/some-project/some-prefix/name") | ||
.put("gcr.io", "gcr.io/some-project/some-prefix/name") | ||
.put("eu.gcr.io", "eu.gcr.io/some-project/some-prefix/name") | ||
.put( | ||
"us-docker.pkg.dev/other-project/other-repo", | ||
"us-docker.pkg.dev/other-project/other-repo/some-prefix/name") | ||
.build(); | ||
testCases.forEach( | ||
(key, value) -> { | ||
// workaround for null key we intended to test | ||
if (Strings.isNullOrEmpty(key)) { | ||
key = null; | ||
} | ||
assertEquals( | ||
value, | ||
TemplatesStageMojo.generateFlexTemplateImagePath( | ||
containerName, projectId, null, key, stagePrefix)); | ||
}); | ||
} | ||
|
||
@Test | ||
public void testGenerateFlexTemplateImagePathWithDomain() { | ||
String containerName = "name"; | ||
String projectId = "google.com:project"; | ||
String stagePrefix = "some-prefix"; | ||
ImmutableMap<String, String> testCases = | ||
ImmutableMap.<String, String>builder() | ||
.put("", "gcr.io/google.com/project/some-prefix/name") | ||
.put("gcr.io", "gcr.io/google.com/project/some-prefix/name") | ||
.put("eu.gcr.io", "eu.gcr.io/google.com/project/some-prefix/name") | ||
.put( | ||
"us-docker.pkg.dev/other-project/other-repo", | ||
"us-docker.pkg.dev/other-project/other-repo/some-prefix/name") | ||
.build(); | ||
testCases.forEach( | ||
(key, value) -> { | ||
// workaround for null key we intended to test | ||
if (Strings.isNullOrEmpty(key)) { | ||
key = null; | ||
} | ||
assertEquals( | ||
value, | ||
TemplatesStageMojo.generateFlexTemplateImagePath( | ||
containerName, projectId, null, key, stagePrefix)); | ||
}); | ||
} | ||
} |