mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-21 07:24:19 +00:00
Run the E2E test on kind / build (push) Failing after 8m1s
Run the E2E test on kind / setup-test-matrix (push) Successful in 4s
Run the E2E test on kind / run-e2e-test (push) Has been skipped
Main CI / Build (push) Failing after 43s
Close stale issues and PRs / stale (push) Successful in 17s
Trivy Nightly Scan / Trivy nightly scan (velero, main) (push) Failing after 1m54s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-aws, main) (push) Failing after 1m43s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-gcp, main) (push) Failing after 1m31s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-microsoft-azure, main) (push) Failing after 1m25s
* Add support for image registry proxy in Kibishii installation Signed-off-by: Priyansh Choudhary <im1706@gmail.com>
90 lines
2.0 KiB
Go
90 lines
2.0 KiB
Go
/*
|
|
Copyright the Velero contributors.
|
|
|
|
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 kibishii
|
|
|
|
import "testing"
|
|
|
|
func TestResolveBasePath(t *testing.T) {
|
|
tests := []struct {
|
|
input string
|
|
expected string
|
|
}{
|
|
{
|
|
input: "/home/user/project/overlays/sc-reclaim-policy/azure",
|
|
expected: "/home/user/project/",
|
|
},
|
|
{
|
|
input: "/go/src/github.com/org/repo/base",
|
|
expected: "/go/src/github.com/org/repo/base",
|
|
},
|
|
{
|
|
input: "/some/dir/overlays",
|
|
expected: "/some/dir/",
|
|
},
|
|
{
|
|
input: "overlays/sc-reclaim-policy/azure",
|
|
expected: "",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
actual := resolveBasePath(tt.input)
|
|
if actual != tt.expected {
|
|
t.Errorf("resolveBasePath(%q) = %q; want %q", tt.input, actual, tt.expected)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestStripRegistry(t *testing.T) {
|
|
tests := []struct {
|
|
input string
|
|
expected string
|
|
}{
|
|
{
|
|
input: "quay.io/example/image:tag",
|
|
expected: "example/image:tag",
|
|
},
|
|
{
|
|
input: "docker.io/library/nginx:latest",
|
|
expected: "library/nginx:latest",
|
|
},
|
|
{
|
|
input: "gcr.io/project/app",
|
|
expected: "project/app",
|
|
},
|
|
{
|
|
input: "my-custom-reg.io/myapp",
|
|
expected: "myapp",
|
|
},
|
|
{
|
|
input: "ubuntu:20.04",
|
|
expected: "ubuntu:20.04",
|
|
},
|
|
{
|
|
input: "library/nginx",
|
|
expected: "library/nginx",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
actual := stripRegistry(tt.input)
|
|
if actual != tt.expected {
|
|
t.Errorf("stripRegistry(%q) = %q; want %q", tt.input, actual, tt.expected)
|
|
}
|
|
}
|
|
}
|