Download this file
| 1 | package main |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | // CARLOS_REGION_HA reaches Config.RegionHA through regionHAEnabled |
| 6 | // (strconv.ParseBool): only a true value turns the console's create-time |
| 7 | // chooser on; unset, false and garbage leave create as today. |
| 8 | func TestRegionHAEnabledParsesTheSwitch(t *testing.T) { |
| 9 | for v, want := range map[string]bool{"": false, "0": false, "false": false, "no": false, "garbage": false, |
| 10 | "1": true, "t": true, "true": true, "TRUE": true, " true ": true} { |
| 11 | got := regionHAEnabled(func(k string) string { |
| 12 | if k != "CARLOS_REGION_HA" { |
| 13 | t.Fatalf("read %s", k) |
| 14 | } |
| 15 | return v |
| 16 | }) |
| 17 | if got != want { |
| 18 | t.Errorf("CARLOS_REGION_HA=%q: %v, want %v", v, got, want) |
| 19 | } |
| 20 | } |
| 21 | } |
| 22 | |