fs_test.go
This file
Path
internal/fs/fs_test.go
49 lines · 894 bytes · Go
Last changed by
test(internal/fs): fix test function name (#4235)Salim Absibefore adoption2e2bd1f
History of this fileTake it
The walk stopped after 200 commits: lines older than cf32d2d point at it.
chore(deps): bump github.com/pelletier/go-toml/v2 from 2.2.2 to 2.2.4 (#4212)dependabot[bot]before adoptioncf32d2d
lines 1–20why, one step back1package fs23import (4 "errors"5 "net/http"6 "os"7 "testing"89 "github.com/stretchr/testify/assert"10 "github.com/stretchr/testify/require"11)1213type mockFileSystem struct {14 open func(name string) (http.File, error)15}1617func (m *mockFileSystem) Open(name string) (http.File, error) {18 return m.open(name)19}20test(internal/fs): fix test function name (#4235)Salim Absibefore adoption2e2bd1f
line 21why, one step back21func TestFileSystem_Open(t *testing.T) {chore(deps): bump github.com/pelletier/go-toml/v2 from 2.2.2 to 2.2.4 (#4212)dependabot[bot]before adoptioncf32d2d
lines 22–49why, one step back22 var testFile *os.File23 mockFS := &mockFileSystem{24 open: func(name string) (http.File, error) {25 return testFile, nil26 },27 }28 fs := &FileSystem{mockFS}2930 file, err := fs.Open("foo")3132 require.NoError(t, err)33 assert.Equal(t, testFile, file)34}3536func TestFileSystem_Open_err(t *testing.T) {37 testError := errors.New("mock")38 mockFS := &mockFileSystem{39 open: func(_ string) (http.File, error) {40 return nil, testError41 },42 }43 fs := &FileSystem{mockFS}4445 file, err := fs.Open("foo")4647 require.ErrorIs(t, err, testError)48 assert.Nil(t, file)49}