Skip to content

Commit

Permalink
nydusify: fix unit test fail in utils
Browse files Browse the repository at this point in the history
Signed-off-by: Yadong Ding <ding_yadong@foxmail.com>
  • Loading branch information
Desiki-high committed Dec 25, 2023
1 parent 2cd8ba2 commit bfd9342
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions contrib/nydusify/pkg/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ package utils
import (
"archive/tar"
"compress/gzip"
"fmt"
"io"
"net/http"
"os"
"strings"
"syscall"
"testing"

"github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -241,11 +242,11 @@ func TestWithRetry(t *testing.T) {
_, err := http.Get("http://localhost:5000")
return err
})
require.Contains(t, err.Error(), "connect: connection refused")
require.ErrorIs(t, err, syscall.ECONNREFUSED)
}

func TestRetryWithHTTP(t *testing.T) {
require.True(t, RetryWithHTTP(fmt.Errorf("server gave HTTP response to HTTPS client")))
require.True(t, RetryWithHTTP(errors.Wrap(http.ErrSchemeMismatch, "parse Nydus image")))
require.False(t, RetryWithHTTP(nil))
}

Expand Down

0 comments on commit bfd9342

Please sign in to comment.