MCPcopy Create free account
hub / github.com/google/git-appraise / TestBuildCommentThreads

Function TestBuildCommentThreads

review/review_test.go:547–629  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

545}
546
547func TestBuildCommentThreads(t *testing.T) {
548 rejected := false
549 accepted := true
550 root := comment.Comment{
551 Timestamp: "012345",
552 Resolved: nil,
553 Description: "root",
554 }
555 rootHash, err := root.Hash()
556 if err != nil {
557 t.Fatal(err)
558 }
559 child := comment.Comment{
560 Timestamp: "012346",
561 Resolved: nil,
562 Parent: rootHash,
563 Description: "child",
564 }
565 childHash, err := child.Hash()
566 updatedChild := comment.Comment{
567 Timestamp: "012346",
568 Resolved: &rejected,
569 Original: childHash,
570 Description: "updated child",
571 }
572 updatedChildHash, err := updatedChild.Hash()
573 if err != nil {
574 t.Fatal(err)
575 }
576 leaf := comment.Comment{
577 Timestamp: "012347",
578 Resolved: &accepted,
579 Parent: childHash,
580 Description: "leaf",
581 }
582 leafHash, err := leaf.Hash()
583 if err != nil {
584 t.Fatal(err)
585 }
586 commentsByHash := map[string]comment.Comment{
587 rootHash: root,
588 childHash: child,
589 updatedChildHash: updatedChild,
590 leafHash: leaf,
591 }
592 threads := buildCommentThreads(commentsByHash)
593 if len(threads) != 1 {
594 t.Fatalf("Unexpected threads: %v", threads)
595 }
596 rootThread := threads[0]
597 if rootThread.Comment.Description != "root" {
598 t.Fatalf("Unexpected root thread: %v", rootThread)
599 }
600 if !rootThread.Edited {
601 t.Fatalf("Unexpected root thread edited status: %v", rootThread)
602 }
603 if len(rootThread.Children) != 1 {
604 t.Fatalf("Unexpected root children: %v", rootThread.Children)

Callers

nothing calls this directly

Calls 2

HashMethod · 0.95
buildCommentThreadsFunction · 0.85

Tested by

no test coverage detected