Skip to content

Commit

Permalink
Merge pull request #40 from gowizzard/development
Browse files Browse the repository at this point in the history
fix: Update go version to 1.20 & import testing.
  • Loading branch information
gowizzard authored Feb 13, 2023
2 parents 94ef20c + 6428ccf commit 368a290
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/gowizzard/dotenv/v2

go 1.19
go 1.20
23 changes: 10 additions & 13 deletions import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package dotenv_test

import (
"errors"
"github.com/gowizzard/dotenv/v2"
"os"
"path/filepath"
Expand All @@ -22,7 +23,7 @@ func TestImport(t *testing.T) {
perm os.FileMode
data []byte
write bool
error bool
error error
expected map[string]string
}{
{
Expand All @@ -31,7 +32,7 @@ func TestImport(t *testing.T) {
perm: os.ModePerm,
data: []byte("TEST1=value\nTEST2=25"),
write: true,
error: false,
error: nil,
expected: map[string]string{
"TEST1": "value",
"TEST2": "25",
Expand All @@ -43,7 +44,7 @@ func TestImport(t *testing.T) {
perm: os.ModePerm,
data: []byte("TEST1='value'\nTEST2='25'\nTEST3='42.5'\nTEST4='true'"),
write: true,
error: false,
error: nil,
expected: map[string]string{
"TEST1": "value",
"TEST2": "25",
Expand All @@ -57,7 +58,7 @@ func TestImport(t *testing.T) {
perm: os.ModePerm,
data: []byte("# This is a test command.\nTEST1=\"value\""),
write: true,
error: false,
error: nil,
expected: map[string]string{
"TEST1": "value",
},
Expand All @@ -68,7 +69,7 @@ func TestImport(t *testing.T) {
perm: os.ModePerm,
data: nil,
write: false,
error: true,
error: errors.New("open : no such file or directory"),
expected: nil,
},
{
Expand All @@ -77,7 +78,7 @@ func TestImport(t *testing.T) {
perm: os.ModePerm,
data: []byte(""),
write: true,
error: true,
error: errors.New("file is empty"),
expected: nil,
},
{
Expand All @@ -86,7 +87,7 @@ func TestImport(t *testing.T) {
perm: os.ModePerm,
data: []byte("=value\n=25"),
write: true,
error: true,
error: errors.New("no matches found"),
expected: nil,
},
}
Expand All @@ -105,12 +106,8 @@ func TestImport(t *testing.T) {
}

err := dotenv.Import(value.path)
if err != nil && !value.error {
t.Error(err)
}

if value.error {
return
if err != nil && !reflect.DeepEqual(value.error.Error(), err.Error()) {
t.Errorf("expected error: \"%v\", got \"%s\"", value.error, err)
}

for index, value := range value.expected {
Expand Down

0 comments on commit 368a290

Please sign in to comment.