diff options
author | Slack Coder <slackcoder@server.ky> | 2023-11-24 13:59:36 -0500 |
---|---|---|
committer | Slack Coder <slackcoder@server.ky> | 2023-11-25 14:09:17 -0500 |
commit | 2b23d8b0e3e47b91aed7ce775c581dafd3d5016b (patch) | |
tree | 029c5c875c7a4de792609ecc8f0a017824d39e6b | |
parent | e2c4903c6fe7bcae7af073fa519343b9ce2b1b28 (diff) | |
download | slackware.com-cli-2b23d8b0e3e47b91aed7ce775c581dafd3d5016b.tar.xz |
Test mirror integration
-rw-r--r-- | internal/slackware_com/mirror_test.go | 29 |
1 files changed, 29 insertions, 0 deletions
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") +} |