Skip to content

Commit

Permalink
replace last occurence of afero with osFs
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed Jan 25, 2022
1 parent bd2a7a8 commit efb972f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/pmezard/go-difflib v1.0.0
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546
github.com/spf13/afero v1.8.0
github.com/spf13/afero v1.8.0 // indirect
github.com/stretchr/testify v1.7.0
github.com/vektra/mockery/v2 v2.9.4
github.com/zclconf/go-cty v1.10.0
Expand Down
23 changes: 21 additions & 2 deletions internal/terraform/parser/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package parser

import (
"fmt"
"io/fs"
"os"
"path/filepath"
"testing"

"github.com/google/go-cmp/cmp"
"github.com/hashicorp/hcl/v2"
"github.com/hashicorp/terraform-ls/internal/terraform/ast"
"github.com/spf13/afero"
)

func TestParseModuleFiles(t *testing.T) {
Expand Down Expand Up @@ -82,7 +83,7 @@ func TestParseModuleFiles(t *testing.T) {
},
}

fs := afero.NewIOFS(afero.NewOsFs())
fs := osFs{}

for i, tc := range testCases {
t.Run(fmt.Sprintf("%d-%s", i, tc.dirName), func(t *testing.T) {
Expand Down Expand Up @@ -112,3 +113,21 @@ func mapKeys(mf ast.ModFiles) map[string]struct{} {
}
return m
}

type osFs struct{}

func (osfs osFs) Open(name string) (fs.File, error) {
return os.Open(name)
}

func (osfs osFs) Stat(name string) (fs.FileInfo, error) {
return os.Stat(name)
}

func (osfs osFs) ReadDir(name string) ([]fs.DirEntry, error) {
return os.ReadDir(name)
}

func (osfs osFs) ReadFile(name string) ([]byte, error) {
return os.ReadFile(name)
}

0 comments on commit efb972f

Please sign in to comment.