Skip to content

Commit b21ee0a

Browse files
committed
fix linter and tests service init
1 parent 672b6e5 commit b21ee0a

File tree

5 files changed

+25
-11
lines changed

5 files changed

+25
-11
lines changed

packages/envd/internal/services/filesystem/dir_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestListDir(t *testing.T) {
3434
require.NoError(t, os.WriteFile(filePath, []byte("Hello, World!"), 0o644))
3535

3636
// Service instance
37-
svc := Service{}
37+
svc := mockService()
3838

3939
// Helper to inject user into context
4040
injectUser := func(ctx context.Context, u *user.User) context.Context {
@@ -106,7 +106,7 @@ func TestListDir(t *testing.T) {
106106
func TestListDirNonExistingPath(t *testing.T) {
107107
t.Parallel()
108108

109-
svc := Service{}
109+
svc := mockService()
110110
u, err := user.Current()
111111
require.NoError(t, err)
112112
ctx := authn.SetInfo(t.Context(), u)
@@ -136,7 +136,7 @@ func TestListDirRelativePath(t *testing.T) {
136136
require.NoError(t, os.WriteFile(filePath, []byte("Hello, World!"), 0o644))
137137

138138
// Service instance
139-
svc := Service{}
139+
svc := mockService()
140140
ctx := authn.SetInfo(t.Context(), u)
141141

142142
req := connect.NewRequest(&filesystem.ListDirRequest{
@@ -188,7 +188,7 @@ func TestListDir_Symlinks(t *testing.T) {
188188
require.NoError(t, os.Symlink(realFile, linkToFile))
189189
require.NoError(t, os.Symlink(cyclicLink, cyclicLink))
190190

191-
svc := Service{}
191+
svc := mockService()
192192

193193
t.Run("symlink to directory behaves like directory and the content looks like inside the directory", func(t *testing.T) {
194194
t.Parallel()

packages/envd/internal/services/filesystem/move_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func TestMove(t *testing.T) {
4040
destFile := filepath.Join(destDir, "test-file.txt")
4141

4242
// Service instance
43-
svc := Service{}
43+
svc := mockService()
4444

4545
// Call the Move function
4646
ctx := authn.SetInfo(t.Context(), u)
@@ -97,7 +97,7 @@ func TestMoveDirectory(t *testing.T) {
9797
destDir := filepath.Join(destParent, "test-dir")
9898

9999
// Service instance
100-
svc := Service{}
100+
svc := mockService()
101101

102102
// Call the Move function
103103
ctx := authn.SetInfo(t.Context(), u)
@@ -157,7 +157,7 @@ func TestMoveNonExistingFile(t *testing.T) {
157157
destFile := filepath.Join(destDir, "moved-file.txt")
158158

159159
// Service instance
160-
svc := Service{}
160+
svc := mockService()
161161

162162
// Call the Move function
163163
ctx := authn.SetInfo(t.Context(), u)
@@ -199,7 +199,7 @@ func TestMoveRelativePath(t *testing.T) {
199199
destFile := filepath.Join(destFolderPath, "moved-file.txt")
200200

201201
// Service instance
202-
svc := Service{}
202+
svc := mockService()
203203

204204
// Call the Move function with relative paths
205205
ctx := authn.SetInfo(t.Context(), u)
@@ -262,7 +262,7 @@ func TestMove_Symlinks(t *testing.T) {
262262
require.NoError(t, os.Symlink(realDir, linkToDir))
263263
require.NoError(t, os.Symlink(realFile, linkToFile))
264264

265-
svc := Service{}
265+
svc := mockService()
266266

267267
t.Run("move symlink to directory", func(t *testing.T) {
268268
destPath := filepath.Join(destRoot, "moved-link-dir")
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package filesystem
2+
3+
import (
4+
"github.com/e2b-dev/infra/packages/envd/internal/execcontext"
5+
"github.com/e2b-dev/infra/packages/envd/internal/utils"
6+
)
7+
8+
func mockService() Service {
9+
return Service{
10+
defaults: &execcontext.Defaults{
11+
EnvVars: utils.NewMap[string, string](),
12+
},
13+
}
14+
}

packages/envd/internal/services/filesystem/stat_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func TestStat(t *testing.T) {
4444
require.NoError(t, err)
4545

4646
// Service instance
47-
svc := Service{}
47+
svc := mockService()
4848

4949
// Helper to inject user into context
5050
injectUser := func(ctx context.Context, u *user.User) context.Context {

packages/orchestrator/internal/template/build/phases/user/builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (ub *UserBuilder) Prefix() string {
6060
return "base"
6161
}
6262

63-
func (ub *UserBuilder) String(ctx context.Context) (string, error) {
63+
func (ub *UserBuilder) String(_ context.Context) (string, error) {
6464
return fmt.Sprintf("DEFAULT USER %s", ub.user), nil
6565
}
6666

0 commit comments

Comments
 (0)