Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

Commit

Permalink
test environment parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
jehiah committed Nov 15, 2014
1 parent 0b39bb6 commit 7c3b46f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions env_options_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
"os"
"testing"

"github.com/bmizerany/assert"
)

type envTest struct {
testField string `cfg:"target_field" env:"TEST_ENV_FIELD"`
}

func TestLoadEnvForStruct(t *testing.T) {

cfg := make(EnvOptions)
cfg.LoadEnvForStruct(&envTest{})

_, ok := cfg["target_field"]
assert.Equal(t, ok, false)

os.Setenv("TEST_ENV_FIELD", "1234abcd")
cfg.LoadEnvForStruct(&envTest{})
v := cfg["target_field"]
assert.Equal(t, v, "1234abcd")
}

0 comments on commit 7c3b46f

Please sign in to comment.