Skip to content

Commit

Permalink
Fix environment variable not being included
Browse files Browse the repository at this point in the history
  • Loading branch information
wrouesnel committed Oct 20, 2023
1 parent 32a37b9 commit 5611add
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/envutil/inputprocessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func FromEnvironment(env []string) (map[string]string, error) {
RawEnvVar: keyval,
})
}
results[splitKeyVal[0]] = splitKeyVal[1]
}

return results, nil
Expand Down
29 changes: 29 additions & 0 deletions pkg/envutil/inputprocessors_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package envutil_test

import (
"os"
"testing"

"github.com/wrouesnel/p2cli/pkg/envutil"

. "gopkg.in/check.v1"
)

// Hook up gocheck into the "go test" runner.
func Test(t *testing.T) { TestingT(t) }

type testSuite struct{}

var _ = Suite(&testSuite{})

func (s *testSuite) TestFromEnvironment(c *C) {
result, _ := envutil.FromEnvironment([]string{"TESTKEY=1"})
c.Check(result["TESTKEY"], Equals, "1")
}

func (s *testSuite) TestFromEnvironmentUsingEnvironment(c *C) {
os.Setenv("TESTKEY", "1")
result, _ := envutil.FromEnvironment(nil)
os.Unsetenv("TESTKEY")
c.Check(result["TESTKEY"], Equals, "1")
}

0 comments on commit 5611add

Please sign in to comment.