Esempio n. 1
0
File: env_test.go Progetto: TV4/env
func TestDurationDefault(t *testing.T) {
	fallback := 123 * time.Second

	os.Clearenv()

	if got := env.Duration("DURATION_DEFAULT", fallback); got != fallback {
		t.Errorf(`Duration("DURATION_DEFAULT", %#v) = %v, want %v`, fallback, got, fallback)
	}
}
Esempio n. 2
0
File: env_test.go Progetto: TV4/env
func TestDuration(t *testing.T) {
	in, fallback, out := "5s", 10*time.Minute, 5*time.Second

	os.Setenv("DURATION", in)

	if got := env.Duration("DURATION", fallback); got != out {
		t.Errorf(`Duration("DURATION", %#v) = %v, want %v`, in, got, out)
	}
}
Esempio n. 3
0
File: env_test.go Progetto: TV4/env
func ExampleDuration() {
	os.Setenv("DURATION", "23s")

	fmt.Printf("%s", env.Duration("DURATION", 0))
	// Output: 23s
}