Repository: regclient/regclient
Pull request #648 (2024-01-25 15:08:49)

Upgrade olareg and close resources when done
<!--

Commits must be signed indicating your agreement to the [DCO](https://developercertificate.org/).
See [DCO missing](https://github.com/src-d/guide/blob/master/developer-community/fix-DCO.md) for steps to fix a missing signoff.

-->

### Fixes issue

<!-- If this is a bug fix, include "fixes #xxxx", or "closes #xxxx" -->

### Describe the change

Changes to the olareg test harness now require the server to the closed to release scheduled goroutines and memory.
<!-- Include the type of change: bug fix, new feature, breaking change, documentation update -->
<!-- Describe what was changed, why the change was made, and how it was implemented -->

### How to verify it

```shell
make test
```
<!-- Include steps that can be taken to verify the change -->

### Changelog text

- Chore: Upgrade olareg testing harness to latest version.
<!-- If the release changelog should have an entry for this, include it here -->

### Please verify and check that the pull request fulfills the following requirements

<!-- Mark the following with an [X] to verify they are included -->

- [X] Tests have been added or not applicable
- [X] Documentation has been added, updated, or not applicable
- [X] Changes have been rebased to main
- [X] Multiple commits to the same code have been squashed

<!-- markdownlint-disable-file MD041 -->



Patch:
diff --git a/go.mod b/go.mod
index ff63a90..04089db 100644
--- a/go.mod
+++ b/go.mod
@@ -5,7 +5,7 @@ go 1.19
 require (
 	github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7
 	github.com/google/uuid v1.5.0
-	github.com/olareg/olareg v0.0.0-20240113232603-66cb4ed3d767
+	github.com/olareg/olareg v0.0.0-20240124210831-6f69033fe212
 	github.com/opencontainers/go-digest v1.0.0
 	github.com/robfig/cron/v3 v3.0.1
 	github.com/sirupsen/logrus v1.9.3
diff --git a/go.sum b/go.sum
index 9eb62d6..6d396ae 100644
--- a/go.sum
+++ b/go.sum
@@ -10,6 +10,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
 github.com/olareg/olareg v0.0.0-20240113232603-66cb4ed3d767 h1:wMkZ1kqA0IH+z1eDMaFjb/ZeMuZvvHBXDlW8JXBjoZ0=
 github.com/olareg/olareg v0.0.0-20240113232603-66cb4ed3d767/go.mod h1:YazBF7Kwb7UGtorlfDOqMv4cxPXERX55H0xbiIYFzow=
+github.com/olareg/olareg v0.0.0-20240124210831-6f69033fe212 h1:J+ScE7b48gNTblZ7VQs/q1CwfxWA6jgV0tlVMFm1TXU=
+github.com/olareg/olareg v0.0.0-20240124210831-6f69033fe212/go.mod h1:YazBF7Kwb7UGtorlfDOqMv4cxPXERX55H0xbiIYFzow=
 github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=


Test patch:
diff --git a/cmd/regctl/registry_test.go b/cmd/regctl/registry_test.go
index d402541..0b4a1f3 100644
--- a/cmd/regctl/registry_test.go
+++ b/cmd/regctl/registry_test.go
@@ -31,6 +31,11 @@ func TestRegistry(t *testing.T) {
 	}))
 	tsBadURL, _ := url.Parse(tsBad.URL)
 	tsBadHost := tsBadURL.Host
+	t.Cleanup(func() {
+		tsGood.Close()
+		tsBad.Close()
+		_ = regHandler.Close()
+	})
 	tempDir := t.TempDir()
 	t.Setenv(ConfigEnv, filepath.Join(tempDir, "config.json"))
 	tt := []struct {
diff --git a/image_test.go b/image_test.go
index b677e2e..08a102c 100644
--- a/image_test.go
+++ b/image_test.go
@@ -149,7 +149,10 @@ func TestCopy(t *testing.T) {
 		},
 	})
 	ts := httptest.NewServer(regHandler)
-	t.Cleanup(func() { ts.Close() })
+	t.Cleanup(func() {
+		ts.Close()
+		_ = regHandler.Close()
+	})
 	tsURL, _ := url.Parse(ts.URL)
 	tsHost := tsURL.Host
 	rcHosts := []config.Host{
diff --git a/tag_test.go b/tag_test.go
index 15b7fb9..7f8496f 100644
--- a/tag_test.go
+++ b/tag_test.go
@@ -45,6 +45,12 @@ func TestTag(t *testing.T) {
 	tsRO := httptest.NewServer(regROHandler)
 	tsROURL, _ := url.Parse(tsRO.URL)
 	tsROHost := tsROURL.Host
+	t.Cleanup(func() {
+		tsRW.Close()
+		tsRO.Close()
+		_ = regRWHandler.Close()
+		_ = regROHandler.Close()
+	})
 	rcHosts := []config.Host{
 		{
 			Name:      tsRWHost,