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

Function TestStringVar

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

Source from the content-addressed store, hash-verified

182}
183
184func TestStringVar(t *testing.T) {
185 var result string
186 StringVar(&result, "nonexistent", "default")
187 Parse()
188
189 if result != "default" {
190 t.Fatalf("expected result=default, got result=%s", result)
191 }
192
193 err := os.Setenv("string-key", "something-new")
194 if err != nil {
195 t.Fatal("unexpected error", err)
196 }
197
198 StringVar(&result, "string-key", "default")
199 Parse()
200
201 if result != "something-new" {
202 t.Fatalf("expected result=something-new, got result=%s", result)
203 }
204}
205
206func TestStringSlice(t *testing.T) {
207 result := StringSlice("empty", "hi")

Callers

nothing calls this directly

Calls 2

StringVarFunction · 0.85
ParseFunction · 0.70

Tested by

no test coverage detected