2021-06-29 17:52:43 +09:00
|
|
|
package testing
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
2022-02-17 09:16:28 +09:00
|
|
|
func Getenv(t *testing.T, name string, opts ...string) string {
|
2021-06-29 17:52:43 +09:00
|
|
|
t.Helper()
|
|
|
|
|
|
|
|
|
|
v := os.Getenv(name)
|
|
|
|
|
if v == "" {
|
2022-02-17 09:16:28 +09:00
|
|
|
if len(opts) == 0 {
|
|
|
|
|
t.Fatal(name + " must be set")
|
|
|
|
|
}
|
|
|
|
|
v = opts[0]
|
2021-06-29 17:52:43 +09:00
|
|
|
}
|
|
|
|
|
return v
|
|
|
|
|
}
|