fix tests

This commit is contained in:
Alexander Wang 2024-11-24 11:03:03 -08:00
parent 7a4ea253a9
commit 1ecadc576c
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
8 changed files with 10 additions and 7 deletions

View file

@ -1080,6 +1080,13 @@ func (kp *KeyPath) IDA() (ida []String) {
return ida
}
func (kp *KeyPath) StringIDA() (ida []string) {
for _, el := range kp.Path {
ida = append(ida, el.Unbox().ScalarString())
}
return ida
}
func (kp *KeyPath) Copy() *KeyPath {
kp2 := *kp
kp2.Path = nil

View file

@ -349,7 +349,7 @@ func Run(ctx context.Context, ms *xmain.State) (err error) {
if err != nil {
return xmain.UsageErrorf("invalid target: %s", *targetFlag)
}
boardPath = key.IDA()
boardPath = key.StringIDA()
}
ctx, cancel := timelib.WithTimeout(ctx, time.Minute*2)

View file

@ -1230,11 +1230,7 @@ func (c *compiler) validateBoardLinks(g *d2graph.Graph) {
continue
}
formattedIDA := []string{}
for _, id := range linkKey.IDA() {
formattedIDA = append(formattedIDA, id.ScalarString())
}
if slices.Equal(formattedIDA, obj.Graph.IDA()) {
if slices.Equal(linkKey.StringIDA(), obj.Graph.IDA()) {
obj.Link = nil
continue
}

View file

@ -28,7 +28,7 @@ func GetRefRanges(path string, fs map[string]string, boardPath []string, key str
var f *d2ir.Field
if mk.Key != nil {
for _, p := range mk.Key.Path {
f = m.GetField(p.Unbox().ScalarString())
f = m.GetField(p.Unbox())
if f == nil {
return nil, nil, nil
}