| 73 | } |
| 74 | |
| 75 | func TestBoolVar(t *testing.T) { |
| 76 | var result bool |
| 77 | BoolVar(&result, "nonexistent", true) |
| 78 | Parse() |
| 79 | |
| 80 | if result != true { |
| 81 | t.Fatalf("expected result=true, got result=%t", result) |
| 82 | } |
| 83 | |
| 84 | err := os.Setenv("bool-key", "true") |
| 85 | if err != nil { |
| 86 | t.Fatal("unexpected error", err) |
| 87 | } |
| 88 | |
| 89 | BoolVar(&result, "bool-key", false) |
| 90 | Parse() |
| 91 | |
| 92 | if result != true { |
| 93 | t.Fatalf("expected result=true, got result=%t", true) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | func TestDuration(t *testing.T) { |
| 98 | result := Duration("nonexistent", 15*time.Second) |