Skip to content

Commit

Permalink
rollback change on file
Browse files Browse the repository at this point in the history
  • Loading branch information
ktong committed Feb 4, 2024
1 parent d45b5e3 commit 0c982fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
5 changes: 3 additions & 2 deletions provider/file/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package file_test

import (
"errors"
"strings"
"testing"

"github.com/nil-go/konf/provider/file"
Expand All @@ -33,7 +34,7 @@ func TestFile_Load(t *testing.T) {
{
description: "file (not exist)",
path: "not_found.json",
err: "read file: open not_found.json: no such file or directory",
err: "read file: open not_found.json: ",
},
{
description: "unmarshal error",
Expand All @@ -55,7 +56,7 @@ func TestFile_Load(t *testing.T) {

values, err := file.New(testcase.path, testcase.opts...).Load()
if testcase.err != "" {
assert.EqualError(t, err, testcase.err)
assert.True(t, strings.HasPrefix(err.Error(), testcase.err))
} else {
assert.NoError(t, err)
assert.Equal(t, testcase.expected, values)
Expand Down
9 changes: 3 additions & 6 deletions provider/file/internal/assert/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@ func NoError(tb testing.TB, err error) {
}
}

func EqualError(tb testing.TB, err error, message string) {
func True(tb testing.TB, value bool) {
tb.Helper()

switch {
case err == nil:
tb.Errorf("expected: %v; actual: <nil>", message)
case err.Error() != message:
tb.Errorf("expected: %v; actual: %v", message, err.Error())
if !value {
tb.Errorf("expected True")
}
}

0 comments on commit 0c982fe

Please sign in to comment.