Skip to content

Commit 376f0cf

Browse files
committed
Revert moving mockFs to testutils.
1 parent c5f130a commit 376f0cf

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

internal/testutil/mocks.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package testutil
33
import (
44
"context"
55
"errors"
6-
"io/fs"
76

87
"github.com/cybertec-postgresql/pgwatch/v3/api/pb"
98
"github.com/cybertec-postgresql/pgwatch/v3/internal/metrics"
@@ -106,11 +105,3 @@ func (m *MockSourcesReaderWriter) DeleteSource(name string) error {
106105
func (m *MockSourcesReaderWriter) WriteSources(srcs sources.Sources) error {
107106
return m.WriteSourcesFunc(srcs)
108107
}
109-
110-
type MockFS struct {
111-
OpenFunc func(name string) (fs.File, error)
112-
}
113-
114-
func (m MockFS) Open(name string) (fs.File, error) {
115-
return m.OpenFunc(name)
116-
}

internal/webserver/webserver_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,18 @@ import (
1111
"testing"
1212

1313
"github.com/cybertec-postgresql/pgwatch/v3/internal/metrics"
14-
"github.com/cybertec-postgresql/pgwatch/v3/internal/testutil"
1514
"github.com/sirupsen/logrus"
1615
"github.com/stretchr/testify/assert"
1716
)
1817

18+
type mockFS struct {
19+
OpenFunc func(name string) (fs.File, error)
20+
}
21+
22+
func (m mockFS) Open(name string) (fs.File, error) {
23+
return m.OpenFunc(name)
24+
}
25+
1926

2027
func TestServer_handleStatic(t *testing.T) {
2128
tempFile := path.Join(t.TempDir(), "file.ext")
@@ -27,7 +34,7 @@ func TestServer_handleStatic(t *testing.T) {
2734
origUIFS := uiFS
2835
defer func() { uiFS = origUIFS }()
2936

30-
uiFS = testutil.MockFS{
37+
uiFS = mockFS{
3138
OpenFunc: func(name string) (fs.File, error) {
3239
switch name {
3340
case "index.html", "static/file.ext":

0 commit comments

Comments
 (0)