Skip to content

Commit

Permalink
nydusify: fix error in go vet
Browse files Browse the repository at this point in the history
`sudo` in action will change go env, remove sudo.
In runner user, we can create file in unpacktargz-test inseted of temp/unpacktargz-test,
so don't use os.CreateTemp in archive_test.go.

Signed-off-by: Yadong Ding <[email protected]>
  • Loading branch information
Desiki-high committed Dec 25, 2023
1 parent 8d2f0e9 commit bd02185
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ jobs:
- name: Unit Test
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/bin v1.54.2
sudo make -e DOCKER=false contrib-test
make -e DOCKER=false contrib-test
- name: Upload contrib coverage file
uses: actions/upload-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion contrib/nydusify/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ coverage: test

clean:
rm -f cmd/nydusify
rm -f coverage.out
rm -f coverage.txt
19 changes: 0 additions & 19 deletions contrib/nydusify/pkg/utils/archive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
package utils

import (
"context"
"io"
"os"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestPackTargzInfo(t *testing.T) {
Expand All @@ -29,19 +26,3 @@ func TestPackTargzInfo(t *testing.T) {
assert.Equal(t, "sha256:6cdd1b26d54d5852fbea95a81cbb25383975b70b4ffad9f9b6d25c7a434a51eb", digest.String())
assert.Equal(t, size, int64(315))
}

func TestUnpackTargz(t *testing.T) {
file, err := os.CreateTemp("", "nydusify-test")
defer os.RemoveAll(file.Name())
require.NoError(t, err)
err = os.WriteFile(file.Name(), []byte("123456789"), 0666)
require.NoError(t, err)
reader, err := PackTargz(file.Name(), file.Name(), true)
require.NoError(t, err)

err = UnpackTargz(context.Background(), "test", io.Reader(reader), false)
defer os.RemoveAll("test")
require.NoError(t, err)
err = UnpackTargz(context.Background(), "test", io.Reader(reader), true)
require.NoError(t, err)
}

0 comments on commit bd02185

Please sign in to comment.