Skip to content

Commit

Permalink
use File() in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 committed Jul 6, 2024
1 parent 38c5105 commit 511fa3f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions value_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestFileValueSource(t *testing.T) {
r.Implements((*ValueSource)(nil), &fileValueSource{})

t.Run("not found", func(t *testing.T) {
src := &fileValueSource{Path: fmt.Sprintf("junk_file_name-%[1]v", rand.Int())}
src := File(fmt.Sprintf("junk_file_name-%[1]v", rand.Int()))
_, ok := src.Lookup()
r.False(ok)
})
Expand All @@ -82,27 +82,27 @@ func TestFileValueSource(t *testing.T) {
r.Nil(os.WriteFile(fileName, []byte("pita"), 0o644))

t.Run("found", func(t *testing.T) {
src := &fileValueSource{Path: fileName}
src := File(fileName)
str, ok := src.Lookup()
r.True(ok)
r.Equal("pita", str)
})
})

t.Run("implements fmt.Stringer", func(t *testing.T) {
src := &fileValueSource{Path: "/dev/null"}
src := File("/dev/null")
r := require.New(t)

r.Implements((*ValueSource)(nil), src)
r.Equal("file \"/dev/null\"", src.String())
})

t.Run("implements fmt.GoStringer", func(t *testing.T) {
src := &fileValueSource{Path: "/dev/null"}
src := File("/dev/null")
r := require.New(t)

r.Implements((*ValueSource)(nil), src)
r.Equal("&fileValueSource{Path:\"/dev/null\"}", src.GoString())
r.Equal("File(Path:\"/dev/null\"}", src.GoString())
})
}

Expand Down

0 comments on commit 511fa3f

Please sign in to comment.