Created
October 10, 2018 18:32
-
-
Save armhold/bada346d685fb518dc53f84bf95cc50f to your computer and use it in GitHub Desktop.
show that envy fails to set GO_ENV to "test" until Reload() is called
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package envious | |
import ( | |
"github.com/gobuffalo/envy" | |
"testing" | |
) | |
// fails | |
func TestGO_ENV(t *testing.T) { | |
assertTestMode(t) | |
} | |
// succeeds | |
func TestGO_ENVWithReload(t *testing.T) { | |
envy.Reload() // by this point test environment is inited, so GO_ENV gets set properly here | |
assertTestMode(t) | |
} | |
func assertTestMode(t *testing.T) { | |
env := envy.Get("GO_ENV", "development") | |
if env != "test" { | |
t.Errorf("expected: 'test', got: '%s'", env) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment