INNER CODE UNIT · Go

Test_valOrGetenv

cweill/gotests · gotests/main_test.go:10

func Test_valOrGetenv(t *testing.T) {
	const (
		testEnvVarKey = "GOTESTS_TEST_KEY"
		testEnvVarVal = "testify"
	)

	if err := os.Setenv(testEnvVarKey, testEnvVarVal); err != nil {
		t.Fatalf("setting environment variable: %v", err)
	}

	defer func(t *testing.T) {
		if err := os.Unsetenv(testEnvVarKey); err != nil {
			t.Fatalf("unsetting environment variable: %v", err)
		}
	}(t)

	type args struct {
		val string

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…