Skip to content

Commit

Permalink
chore: update linter
Browse files Browse the repository at this point in the history
  • Loading branch information
soulteary committed Jun 24, 2024
1 parent 95fb8e7 commit 5a606b1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
go-version: ${{ env.GO_VERSION }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
Expand Down
8 changes: 2 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ linters:
fast: false
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
- errcheck
Expand All @@ -29,13 +27,11 @@ linters:
- nolintlint
- rowserrcheck
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
- gofumpt

Expand All @@ -46,6 +42,7 @@ linters-settings:
files:
- $all
- "!$test"
- "!*_test.go"
allow:
- github.com/gin-gonic/gin
- embed
Expand All @@ -57,5 +54,4 @@ linters-settings:
- fmt

run:
timeout: 3m
tests: false
timeout: 3m
13 changes: 8 additions & 5 deletions embed_folder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
var testFS embed.FS

func TestEmbedFolderWithRedir(t *testing.T) {
var tests = []struct {
tests := []struct {
targetURL string // input
httpCode int // expected http code
httpBody string // expected http body
Expand Down Expand Up @@ -50,7 +50,7 @@ func TestEmbedFolderWithRedir(t *testing.T) {
}

func TestEmbedFolderWithoutRedir(t *testing.T) {
var tests = []struct {
tests := []struct {
targetURL string // input
httpCode int // expected http code
httpBody string // expected http body
Expand Down Expand Up @@ -118,7 +118,7 @@ func TestCreateEmbed(t *testing.T) {
}

func TestServEmbed(t *testing.T) {
var tests = []struct {
tests := []struct {
targetURL string // input
httpCode int // expected http code
httpBody string // expected http body
Expand Down Expand Up @@ -162,6 +162,9 @@ func TestServEmbed(t *testing.T) {
}

func TestServEmbedErr(t *testing.T) {
embedDir := "111111test/data/server"
message := fmt.Sprintf("open %s: file does not exist", embedDir)

tests := []struct {
name string
URL string
Expand All @@ -172,12 +175,12 @@ func TestServEmbedErr(t *testing.T) {
name: "Invalid Path",
URL: "/test/data/server/nonexistingdirectory/nonexistingdirectory",
Code: http.StatusInternalServerError,
Result: "{\"error\":\"open 111111test/data/server: file does not exist\",\"message\":\"initialization of embed folder failed\"}",
Result: fmt.Sprintf("{\"error\":\"%s\",\"message\":\"initialization of embed folder failed\"}", message),
},
}

router := gin.New()
router.Use(static.ServeEmbed("111111test/data/server", testFS))
router.Use(static.ServeEmbed(embedDir, testFS))
for _, tt := range tests {
w := PerformRequest(router, "GET", tt.URL)
assert.Equal(t, w.Code, tt.Code)
Expand Down
4 changes: 2 additions & 2 deletions local_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ func TestLocalFile(t *testing.T) {
t.Error(err)
}
defer os.Remove(f.Name())
f.WriteString("Gin Web Framework")
f.Close()
_, _ = f.WriteString("Gin Web Framework")
_ = f.Close()

dir, filename := filepath.Split(f.Name())
router := gin.New()
Expand Down
1 change: 0 additions & 1 deletion serve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/stretchr/testify/assert"
)

// nolint:unparam
func PerformRequest(r http.Handler, method, path string) *httptest.ResponseRecorder {
req, _ := http.NewRequestWithContext(context.Background(), method, path, nil)
w := httptest.NewRecorder()
Expand Down

0 comments on commit 5a606b1

Please sign in to comment.