package check import ( "encoding/json" "reflect" "testing" ) // I8, ADR 0499 clause 2: the preview carries each named path's object a fetch's module trees answer (mesh-sdk // buildstep.ModuleTree's paths), so the indexer computes the candidate's narrowed tree from them by the one function. func TestAPreviewCarriesTheNamedPathsObjectsOfAFetchsModuleTrees(t *testing.T) { var f Fetched // As buildstep.ModuleTrees answers a module naming its paths: the named tree and the objects. raw := `{"workspace":"w","merge":"6666666666666666666666666666666666666666","trees":{".":{"tree":"named:aa","manifest":"` + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + `","paths":{"src":"1111111111111111111111111111111111111111"}}}}` if err := json.Unmarshal([]byte(raw), &f); err != nil { t.Fatal(err) } pv, ok := PreviewOf(Pull{Repository: "novox/mesh-sdk", Head: "h", Trunk: "t"}, []Fetched{f}) if !ok || !reflect.DeepEqual(pv.Modules["."].Paths, map[string]string{"src": "1111111111111111111111111111111111111111"}) || pv.Modules["."].Tree != "named:aa" { t.Errorf("preview = %+v, want the module's named tree and its objects", pv) } }