Skip to content

Instantly share code, notes, and snippets.

@armhold
Created October 10, 2018 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save armhold/bada346d685fb518dc53f84bf95cc50f to your computer and use it in GitHub Desktop.
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
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