MCPcopy Create free account
hub / github.com/prometheus/common / TestUnmarshalNullURL

Function TestUnmarshalNullURL

config/http_config_test.go:2203–2220  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2201}
2202
2203func TestUnmarshalNullURL(t *testing.T) {
2204 b := []byte(`null`)
2205
2206 {
2207 var u URL
2208 err := json.Unmarshal(b, &u)
2209 require.NoError(t, err)
2210 require.Truef(t, isEmptyNonNilURL(u.URL), "`null` literal not properly unmarshaled from JSON as URL, got %#v", u.URL)
2211 }
2212
2213 {
2214 var u URL
2215 err := yaml.Unmarshal(b, &u)
2216 require.NoError(t, err)
2217 // UnmarshalYAML is not called when parsing null literal.
2218 require.Nilf(t, u.URL, "`null` literal not properly unmarshaled from YAML as URL, got %#v", u.URL)
2219 }
2220}
2221
2222func TestUnmarshalEmptyURL(t *testing.T) {
2223 b := []byte(`""`)

Callers

nothing calls this directly

Calls 1

isEmptyNonNilURLFunction · 0.85

Tested by

no test coverage detected