func TestGetNeighbors(t *testing.T) { gm = new(spiderDB.GraphManager) gm.Initialize() defer gm.ClearAll() hgw := socialGraph.NewSocialNode("http://upload.wikimedia.org/wikipedia/commons/thumb/7/7f/H_G_Wells_pre_1922.jpg/220px-H_G_Wells_pre_1922.jpg", "Herbert Wells", "H.G.", "*****@*****.**", "Writer", "SciFi", "whatisgithub?", gm) msg := socialGraph.NewMessageNode("Will he ever return?") edg := socialGraph.NewSocialEdge(1898, "jittered", gm) gm.AddNode(hgw) gm.AddNode(msg) gm.AddEdge(edg) gm.Attach(hgw, msg, edg) neighbors, err := gm.GetNeighbors(hgw, socialGraph.SocialEdgeConst, socialGraph.SocialNodeConst) if err != nil { t.Error(err.Error()) } if len(neighbors) != 1 { fmt.Printf("***************%v ************\n", neighbors) t.Errorf("GetNeighbors Failed - %v neighbors", len(neighbors)) } if err != nil { t.Error(err) } }
func initTestNodes(gm spiderDB.GraphBackend) []*socialGraph.SocialNode { var testNodes []*socialGraph.SocialNode const numdum = 8 pics := [numdum]string{"picTEST", "http://4.bp.blogspot.com/-Q2hjS1dS1R8/T4YXpOfNjOI/AAAAAAAAAxQ/c-V_1FkMYmo/s1600/Bug.jpg", "https://encrypted-tbn1.google.com/images?q=tbn:ANd9GcRs5AS0g3hHRdJsO7gBgwu9v1Hr4grtuc_G1dh59MbxEVW3VH-GNw", "https://encrypted-tbn3.google.com/images?q=tbn:ANd9GcSJVzRTk5jiGvRIcKQZs-pm4__kMQOWae0WGGl3H32xZCTvci9U", "https://encrypted-tbn3.google.com/images?q=tbn:ANd9GcQ6VCAy3UhBqNohPBG1Dr5nVd2WfwTLnINK_pmh0Wo7RUPh7vwpjw", "https://encrypted-tbn1.google.com/images?q=tbn:ANd9GcQ677iObh3n9DhnfwvpFUH-ksX9mXv3kyS_h7npytmLACpe9EZX", "https://encrypted-tbn3.google.com/images?q=tbn:ANd9GcR94C_rLFc1arqiV_Dmi6LHIQzEVWvOFJg7TxdpdR-PxtVxVLAr", "https://encrypted-tbn3.google.com/images?q=tbn:ANd9GcRPaCON4nIzFMqrfCVuWAn8HoD0zH-ir-KovxFxwgy6ocUlYxHJ"} bios := [numdum]string{ "bioTEST", "I don't exist", "I am from HERE", "I am from THERE", "I am from A", "I am from B", "I am from C", "I am from D"} names := [numdum]string{"nameTEST", "Wedunno", "Joe", "Bill", "Jane", "Sue", "Sally", "Tom"} users := [numdum]string{"userTEST", "Whothatis", "jmk", "bill-o-rama", "sparkles", "user", "user", "uzaaah"} github := [numdum]string{"githubTEST", "http://github.com/IAMAUSER", "http://github.com/IAMAUSER", "http://github.com/IAMAUSER", "http://github.com/IAMAUSER", "http://github.com/IAMAUSER", "http://github.com/IAMAUSER", "http://github.com/IAMAUSER"} for k, _ := range pics { newNode := socialGraph.NewSocialNode(pics[k], names[k], users[k], "emailTEST", bios[k], "skillsTEST", github[k], gm) testNodes = append(testNodes, newNode) } return testNodes }
func initDummys() { gm = new(spiderDB.GraphManager) gm.Initialize() // ======= SOCIAL NODES ======= // const numdum = 8 pics := [numdum]string{"http://content8.flixster.com/question/28/64/25/2864258_std.jpg", "http://4.bp.blogspot.com/-Q2hjS1dS1R8/T4YXpOfNjOI/AAAAAAAAAxQ/c-V_1FkMYmo/s1600/Bug.jpg", "https://encrypted-tbn1.google.com/images?q=tbn:ANd9GcRs5AS0g3hHRdJsO7gBgwu9v1Hr4grtuc_G1dh59MbxEVW3VH-GNw", "https://encrypted-tbn3.google.com/images?q=tbn:ANd9GcSJVzRTk5jiGvRIcKQZs-pm4__kMQOWae0WGGl3H32xZCTvci9U", "https://encrypted-tbn3.google.com/images?q=tbn:ANd9GcQ6VCAy3UhBqNohPBG1Dr5nVd2WfwTLnINK_pmh0Wo7RUPh7vwpjw", "https://encrypted-tbn1.google.com/images?q=tbn:ANd9GcQ677iObh3n9DhnfwvpFUH-ksX9mXv3kyS_h7npytmLACpe9EZX", "https://encrypted-tbn3.google.com/images?q=tbn:ANd9GcR94C_rLFc1arqiV_Dmi6LHIQzEVWvOFJg7TxdpdR-PxtVxVLAr", "https://encrypted-tbn3.google.com/images?q=tbn:ANd9GcRPaCON4nIzFMqrfCVuWAn8HoD0zH-ir-KovxFxwgy6ocUlYxHJ"} bios := [numdum]string{ "bioTEST", "I don't exist", "I am from HERE", "I am from THERE", "I am from A", "I am from B", "I am from C", "I am from D"} names := [numdum]string{"nameTEST", "Wedunno", "Joe", "Bill", "Jane", "Sue", "Sally", "Tom"} users := [numdum]string{"userTEST", "Whothatis", "jmk", "bill-o-rama", "sparkles", "user1", "user2", "uzaaah"} github := [numdum]string{"githubTEST", "http://github.com/IAMAUSER", "http://github.com/IAMAUSER", "http://github.com/IAMAUSER", "http://github.com/IAMAUSER", "http://github.com/IAMAUSER", "http://github.com/IAMAUSER", "http://github.com/IAMAUSER"} for k, _ := range pics { newNode := socialGraph.NewSocialNode(pics[k], names[k], users[k], "*****@*****.**", bios[k], "skills", github[k], gm) gm.AddNode(newNode) } edgF := socialGraph.NewSocialEdge(1, "follows", gm) edgFB := socialGraph.NewSocialEdge(1, "follows", gm) gm.AddEdge(edgF) gm.AddEdge(edgFB) var err error node0, err := gm.GetNode("1", socialGraph.SocialNodeConst) if err != nil { print(err.Error()) } node1, err := gm.GetNode("2", socialGraph.SocialNodeConst) if err != nil { print(err.Error()) } node2, err := gm.GetNode("3", socialGraph.SocialNodeConst) if err != nil { print(err.Error()) } gm.Attach(node0, node1, edgF) gm.Attach(node0, node2, edgFB) // ======= JITS ======= // const numMsg = 4 testJits := make([]*socialGraph.MessageNode, 0) jits := [numMsg]string{"JITTER", "JITJITJITTTER", "Jittttaaaaaah", "Jitterbug!"} for _, v := range jits { newNode := socialGraph.NewMessageNode(v) testJits = append(testJits, newNode) } // ======= JIT EDGES ======= // for _, jitter := range testJits { edgJit := socialGraph.NewSocialEdge(1, "jitted", gm) gm.AddEdge(edgJit) gm.Attach(node0, jitter, edgJit) } }