From 2b23d8b0e3e47b91aed7ce775c581dafd3d5016b Mon Sep 17 00:00:00 2001 From: Slack Coder Date: Fri, 24 Nov 2023 13:59:36 -0500 Subject: Test mirror integration --- internal/slackware_com/mirror_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 internal/slackware_com/mirror_test.go diff --git a/internal/slackware_com/mirror_test.go b/internal/slackware_com/mirror_test.go new file mode 100644 index 0000000..2cc1231 --- /dev/null +++ b/internal/slackware_com/mirror_test.go @@ -0,0 +1,29 @@ +package slackware_com + +import ( + "bytes" + "net/url" + "os" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestMirrorDownloadAndVerify(t *testing.T) { + endpoint, ok := os.LookupEnv("SLACKWARE_MIRROR") + if !ok { + t.Skip("enable test by defining SLACKWARE_MIRROR") + return + } + + mirrorURL, err := url.Parse(endpoint) + require.NoError(t, err) + mirror, err := OpenMirror(mirrorURL) + require.NoError(t, err) + + var buf bytes.Buffer + err = mirror.DownloadAndVerify(&buf, "CHECKSUMS.md5") + require.NoError(t, err) + assert.NotEmpty(t, buf, "must download content") +} -- cgit v1.2.3