freeconf / yang

Standards-based management for Golang microservices
Apache License 2.0
38 stars 14 forks source link

Issue-76 finding choicecase def #88

Closed davidmat50 closed 1 year ago

dhubler commented 1 year ago

This might be better:

if choice, ok := p.(*Choice); ok {
    if c, found := choice.Cases()[path]; found {
        return c
    }
    return nil
}

returning null is ok, just means path doesn't point to a definition.

Can you also add a check to TestFindChoice in find_test.go to find a case returns the case and not finding a case returns nil?

something like:

fc.AssertEqual(t, c1, Find(m, "c/one"))
fc.AssertEqual(t, nil, Find(m, "c/bogus"))
davidmat50 commented 1 year ago

The suggested changes and UTs were done.
If there anything else to be done. If eveything is fine, can you merge the changes to main master branch.