test: tests repo stripping functionality

Signed-off-by: Jesse Simpson <jesse.simpson36@gmail.com>
pull/30916/head
Jesse Simpson 4 months ago
parent 099a9e18f3
commit fe512bae43
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() { func (suite *HTTPRegistryClientTestSuite) Test_1_Push() {
if suite.protocol != "" { if suite.protocol != "" || suite.Repo != "" {
return return
} }
testPush(&suite.TestSuite) testPush(&suite.TestSuite)
} }
func (suite *HTTPRegistryClientTestSuite) Test_2_Pull() { func (suite *HTTPRegistryClientTestSuite) Test_2_Pull() {
if suite.protocol != "" { if suite.protocol != "" || suite.Repo != "" {
return return
} }
testPull(&suite.TestSuite) testPull(&suite.TestSuite)
} }
func (suite *HTTPRegistryClientTestSuite) Test_3_Tags() { func (suite *HTTPRegistryClientTestSuite) Test_3_Tags() {
if suite.protocol != "" { if suite.protocol != "" || suite.Repo != "" {
return return
} }
testTags(&suite.TestSuite) testTags(&suite.TestSuite)
@ -88,6 +88,9 @@ func (suite *HTTPRegistryClientTestSuite) Test_4_ManInTheMiddle() {
func TestHTTPRegistryClientTestSuite(t *testing.T) { func TestHTTPRegistryClientTestSuite(t *testing.T) {
suite.Run(t, new(HTTPRegistryClientTestSuite)) suite.Run(t, new(HTTPRegistryClientTestSuite))
var suiteWithRepo = new(HTTPRegistryClientTestSuite)
suiteWithRepo.Repo = "/testrepo/"
suite.Run(t, suiteWithRepo)
for _, protocol := range []string{"oci://", "http://", "https://"} { for _, protocol := range []string{"oci://", "http://", "https://"} {
var protocolSpecificTestSuite = new(HTTPRegistryClientTestSuite) var protocolSpecificTestSuite = new(HTTPRegistryClientTestSuite)
protocolSpecificTestSuite.protocol = protocol protocolSpecificTestSuite.protocol = protocol

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

Loading…
Cancel
Save