Skip to content

Commit

Permalink
tests: In Go 1.23 fs related errors have changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
aldas committed Aug 15, 2024
1 parent 9a9761f commit 5e3bcc0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
17 changes: 7 additions & 10 deletions echo_fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,19 +245,16 @@ func TestEcho_FileFS(t *testing.T) {

func TestEcho_StaticPanic(t *testing.T) {
var testCases = []struct {
name string
givenRoot string
expectError string
name string
givenRoot string
}{
{
name: "panics for ../",
givenRoot: "../assets",
expectError: "can not create sub FS, invalid root given, err: sub ../assets: invalid name",
name: "panics for ../",
givenRoot: "../assets",
},
{
name: "panics for /",
givenRoot: "/assets",
expectError: "can not create sub FS, invalid root given, err: sub /assets: invalid name",
name: "panics for /",
givenRoot: "/assets",
},
}

Expand All @@ -266,7 +263,7 @@ func TestEcho_StaticPanic(t *testing.T) {
e := New()
e.Filesystem = os.DirFS("./")

assert.PanicsWithError(t, tc.expectError, func() {
assert.Panics(t, func() {
e.Static("../assets", tc.givenRoot)
})
})
Expand Down
17 changes: 7 additions & 10 deletions group_fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,16 @@ func TestGroup_FileFS(t *testing.T) {

func TestGroup_StaticPanic(t *testing.T) {
var testCases = []struct {
name string
givenRoot string
expectError string
name string
givenRoot string
}{
{
name: "panics for ../",
givenRoot: "../images",
expectError: "can not create sub FS, invalid root given, err: sub ../images: invalid name",
name: "panics for ../",
givenRoot: "../images",
},
{
name: "panics for /",
givenRoot: "/images",
expectError: "can not create sub FS, invalid root given, err: sub /images: invalid name",
name: "panics for /",
givenRoot: "/images",
},
}

Expand All @@ -98,7 +95,7 @@ func TestGroup_StaticPanic(t *testing.T) {

g := e.Group("/assets")

assert.PanicsWithError(t, tc.expectError, func() {
assert.Panics(t, func() {
g.Static("/images", tc.givenRoot)
})
})
Expand Down

0 comments on commit 5e3bcc0

Please sign in to comment.