(t *testing.T)
| 1689 | } |
| 1690 | |
| 1691 | func TestSub(t *testing.T) { |
| 1692 | v := New() |
| 1693 | v.SetConfigType("yaml") |
| 1694 | v.ReadConfig(bytes.NewBuffer(yamlExample)) |
| 1695 | |
| 1696 | subv := v.Sub("clothing") |
| 1697 | assert.Equal(t, v.Get("clothing.pants.size"), subv.Get("pants.size")) |
| 1698 | |
| 1699 | subv = v.Sub("clothing.pants") |
| 1700 | assert.Equal(t, v.Get("clothing.pants.size"), subv.Get("size")) |
| 1701 | |
| 1702 | subv = v.Sub("clothing.pants.size") |
| 1703 | assert.Equal(t, (*Viper)(nil), subv) |
| 1704 | |
| 1705 | subv = v.Sub("missing.key") |
| 1706 | assert.Equal(t, (*Viper)(nil), subv) |
| 1707 | |
| 1708 | subv = v.Sub("clothing") |
| 1709 | assert.Equal(t, []string{"clothing"}, subv.parents) |
| 1710 | |
| 1711 | subv = v.Sub("clothing").Sub("pants") |
| 1712 | assert.Equal(t, []string{"clothing", "pants"}, subv.parents) |
| 1713 | } |
| 1714 | |
| 1715 | func TestSubWithKeyDelimiter(t *testing.T) { |
| 1716 | v := NewWithOptions(KeyDelimiter("::")) |
nothing calls this directly
no test coverage detected