| 114 | } |
| 115 | |
| 116 | func TestURL(t *testing.T) { |
| 117 | example := "http://example.com" |
| 118 | newExample := "http://something-new.com" |
| 119 | result := URL("nonexistent", example) |
| 120 | Parse() |
| 121 | |
| 122 | if result.String() != example { |
| 123 | t.Fatalf("expected result=%s, got result=%v", example, result) |
| 124 | } |
| 125 | |
| 126 | err := os.Setenv("url-key", newExample) |
| 127 | if err != nil { |
| 128 | t.Fatal("unexpected error", err) |
| 129 | } |
| 130 | |
| 131 | result = URL("url-key", example) |
| 132 | Parse() |
| 133 | |
| 134 | if result.String() != newExample { |
| 135 | t.Fatalf("expected result=%v, got result=%v", newExample, result) |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | func TestURLVar(t *testing.T) { |
| 140 | example := "http://example.com" |