Skip to content

Instantly share code, notes, and snippets.

@royge
Created July 30, 2020 10:00
Show Gist options
  • Save royge/2e133c58609c524dc83739b49ce5efaf to your computer and use it in GitHub Desktop.
Save royge/2e133c58609c524dc83739b49ce5efaf to your computer and use it in GitHub Desktop.
Check required environment variables in running tests.
package checkenv
import (
"os"
"testing"
)
func CheckEnvs(t *testing.T, envs ...string) {
t.Helper()
for _, env := range envs {
if v := os.Getenv(env); v == "" {
t.Fatalf("environment variable `%s` is not defined", env)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment