test: tests repo stripping functionality

Signed-off-by: Jesse Simpson <jesse.simpson36@gmail.com>
pull/30936/head
Jesse Simpson 4 months ago
parent abee236ebe
commit 9e473ff350
No known key found for this signature in database
GPG Key ID: 237495C89AB0AAFC

@ -57,21 +57,21 @@ func (suite *HTTPRegistryClientTestSuite) Test_0_Login() {
}
func (suite *HTTPRegistryClientTestSuite) Test_1_Push() {
if suite.protocol != "" {
if suite.protocol != "" || suite.Repo != "" {
return
}
testPush(&suite.TestSuite)
}
func (suite *HTTPRegistryClientTestSuite) Test_2_Pull() {
if suite.protocol != "" {
if suite.protocol != "" || suite.Repo != "" {
return
}
testPull(&suite.TestSuite)
}
func (suite *HTTPRegistryClientTestSuite) Test_3_Tags() {
if suite.protocol != "" {
if suite.protocol != "" || suite.Repo != "" {
return
}
testTags(&suite.TestSuite)
@ -88,6 +88,9 @@ func (suite *HTTPRegistryClientTestSuite) Test_4_ManInTheMiddle() {
func TestHTTPRegistryClientTestSuite(t *testing.T) {
suite.Run(t, new(HTTPRegistryClientTestSuite))
var suiteWithRepo = new(HTTPRegistryClientTestSuite)
suiteWithRepo.Repo = "/testrepo/"
suite.Run(t, suiteWithRepo)
for _, protocol := range []string{"oci://", "http://", "https://"} {
var protocolSpecificTestSuite = new(HTTPRegistryClientTestSuite)
protocolSpecificTestSuite.protocol = protocol

@ -65,6 +65,7 @@ type TestSuite struct {
CompromisedRegistryHost string
WorkspaceDir string
RegistryClient *Client
Repo string
// A mock DNS server needed for TLS connection testing.
srv *mockdns.Server
@ -133,10 +134,10 @@ func setup(suite *TestSuite, tlsEnabled, insecure bool) *registry.Registry {
// This is required because Docker enforces HTTP if the registry
// host is localhost/127.0.0.1.
if suite.DockerRegistryHost == "" {
suite.DockerRegistryHost = fmt.Sprintf("helm-test-registry:%d", port)
suite.DockerRegistryHost = fmt.Sprintf("helm-test-registry:%d%s", port, suite.Repo)
} else {
// may programmatically set this for custom protocol handling
suite.DockerRegistryHost = fmt.Sprintf("%s:%d", suite.DockerRegistryHost, port)
suite.DockerRegistryHost = fmt.Sprintf("%s:%d%s", suite.DockerRegistryHost, port, suite.Repo)
}
suite.srv, err = mockdns.NewServer(map[string]mockdns.Zone{
"helm-test-registry.": {

Loading…
Cancel
Save