| 161 | } |
| 162 | |
| 163 | func TestString(t *testing.T) { |
| 164 | result := String("nonexistent", "default") |
| 165 | Parse() |
| 166 | |
| 167 | if *result != "default" { |
| 168 | t.Fatalf("expected result=default, got result=%s", *result) |
| 169 | } |
| 170 | |
| 171 | err := os.Setenv("string-key", "something-new") |
| 172 | if err != nil { |
| 173 | t.Fatal("unexpected error", err) |
| 174 | } |
| 175 | |
| 176 | result = String("string-key", "default") |
| 177 | Parse() |
| 178 | |
| 179 | if *result != "something-new" { |
| 180 | t.Fatalf("expected result=something-new, got result=%s", *result) |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | func TestStringVar(t *testing.T) { |
| 185 | var result string |