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 Feb 9, 2022
1 parent 03b0b98 commit 215ebe5
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.1
github.com/spf13/afero v1.8.1 // indirect
github.com/stretchr/testify v1.7.0
github.com/vektra/mockery/v2 v2.10.0
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 215ebe5

Please sign in to comment.