MCPcopy Index your code
hub / github.com/chain/Core / TestURLVar

Function TestURLVar

env/env_test.go:139–161  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

137}
138
139func TestURLVar(t *testing.T) {
140 example := "http://example.com"
141 newExample := "http://something-new.com"
142 var result url.URL
143 URLVar(&result, "nonexistent", example)
144 Parse()
145
146 if result.String() != example {
147 t.Fatalf("expected result=%s, got result=%v", example, result)
148 }
149
150 err := os.Setenv("url-key", newExample)
151 if err != nil {
152 t.Fatal("unexpected error", err)
153 }
154
155 URLVar(&result, "url-key", example)
156 Parse()
157
158 if result.String() != newExample {
159 t.Fatalf("expected result=%v, got result=%v", newExample, result)
160 }
161}
162
163func TestString(t *testing.T) {
164 result := String("nonexistent", "default")

Callers

nothing calls this directly

Calls 3

URLVarFunction · 0.85
ParseFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected