diff options
-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") +} |