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

Function TestUnmarshalNullURL

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

Source from the content-addressed store, hash-verified

1699}
1700
1701func TestUnmarshalNullURL(t *testing.T) {
1702 b := []byte(`null`)
1703
1704 {
1705 var u URL
1706 err := json.Unmarshal(b, &u)
1707 if err != nil {
1708 t.Fatal(err)
1709 }
1710 if !isEmptyNonNilURL(u.URL) {
1711 t.Fatalf("`null` literal not properly unmarshaled from JSON as URL, got %#v", u.URL)
1712 }
1713 }
1714
1715 {
1716 var u URL
1717 err := yaml.Unmarshal(b, &u)
1718 if err != nil {
1719 t.Fatal(err)
1720 }
1721 if u.URL != nil { // UnmarshalYAML is not called when parsing null literal.
1722 t.Fatalf("`null` literal not properly unmarshaled from YAML as URL, got %#v", u.URL)
1723 }
1724 }
1725}
1726
1727func TestUnmarshalEmptyURL(t *testing.T) {
1728 b := []byte(`""`)

Callers

nothing calls this directly

Calls 1

isEmptyNonNilURLFunction · 0.85

Tested by

no test coverage detected