Skip to content

Commit

Permalink
Merge pull request moby#49015 from thaJeztah/registry_test_cleanups
Browse files Browse the repository at this point in the history
registry: remove assignment of default values in some tests
  • Loading branch information
thaJeztah authored Dec 3, 2024
2 parents 612b853 + 0194a18 commit 84aeea2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 29 deletions.
28 changes: 7 additions & 21 deletions distribution/pull_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,41 +335,27 @@ func testNewPuller(t *testing.T, rawurl string) *puller {
t.Helper()

uri, err := url.Parse(rawurl)
if err != nil {
t.Fatalf("could not parse url from test server: %v", err)
}
assert.NilError(t, err, "could not parse url from test server: %v", rawurl)

n, err := reference.ParseNormalizedNamed("testremotename")
assert.NilError(t, err)

endpoint := registry.APIEndpoint{
Mirror: false,
URL: uri,
Official: false,
TrimHostname: false,
TLSConfig: nil,
}
n, _ := reference.ParseNormalizedNamed("testremotename")
repoInfo := &registry.RepositoryInfo{
Name: n,
Index: &registrytypes.IndexInfo{
Name: "testrepo",
Mirrors: nil,
Secure: false,
Official: false,
Name: "testrepo",
},
Official: false,
}
imagePullConfig := &ImagePullConfig{
Config: Config{
MetaHeaders: http.Header{},
AuthConfig: &registrytypes.AuthConfig{
RegistryToken: secretRegistryToken,
},
},
}

p := newPuller(endpoint, repoInfo, imagePullConfig, nil)
p := newPuller(registry.APIEndpoint{URL: uri}, repoInfo, imagePullConfig, nil)
p.repo, err = newRepository(context.Background(), p.repoInfo, p.endpoint, p.config.MetaHeaders, p.config.AuthConfig, "pull")
if err != nil {
t.Fatal(err)
}
assert.NilError(t, err)
return p
}
9 changes: 1 addition & 8 deletions distribution/registry_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,15 @@ func testTokenPassThru(t *testing.T, ts *httptest.Server) {
}

endpoint := registrypkg.APIEndpoint{
Mirror: false,
URL: uri,
Official: false,
TrimHostname: false,
TLSConfig: nil,
}
n, _ := reference.ParseNormalizedNamed("testremotename")
repoInfo := &registrypkg.RepositoryInfo{
Name: n,
Index: &registry.IndexInfo{
Name: "testrepo",
Mirrors: nil,
Secure: false,
Official: false,
Name: "testrepo",
},
Official: false,
}
imagePullConfig := &ImagePullConfig{
Config: Config{
Expand Down

0 comments on commit 84aeea2

Please sign in to comment.