From 4e4dd4964756e8e1013bf30d1ce13fc41cca37cd Mon Sep 17 00:00:00 2001 From: vialeon Date: Mon, 18 Jan 2021 16:00:25 -0500 Subject: [PATCH 1/3] added contents testing --- pkg/gitqlite/blame_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pkg/gitqlite/blame_test.go b/pkg/gitqlite/blame_test.go index 65fd2b78..7c0a0cf6 100644 --- a/pkg/gitqlite/blame_test.go +++ b/pkg/gitqlite/blame_test.go @@ -50,4 +50,25 @@ func TestBlameDistinctFiles(t *testing.T) { if gotFileCount != expectedFileCount { t.Fatalf("expected %d distinct file paths in blame, got %d", expectedFileCount, gotFileCount) } + iterator, err := NewBlameIterator(fixtureRepo) + if err != nil { + t.Fatal(err) + } + rows, err = fixtureDB.Query("SELECT contents from blame limit 100") + if err != nil { + t.Fatal(err) + } + _, lines, err := GetRowContents(rows) + if err != nil { + t.Fatal(err) + } + for _, line := range lines { + cont, err := iterator.Next() + if err != nil { + t.Fatal(err) + } + if !(line[0] == cont.Content) { + t.Fatalf("expected %s content in blame, got %s", cont.Content, line[0]) + } + } } From 284bb94a519abdc99324ffc1b6778b72a5b7d1ed Mon Sep 17 00:00:00 2001 From: vialeon Date: Mon, 18 Jan 2021 16:04:36 -0500 Subject: [PATCH 2/3] make it a different function --- pkg/gitqlite/blame_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/gitqlite/blame_test.go b/pkg/gitqlite/blame_test.go index 7c0a0cf6..b23bd78b 100644 --- a/pkg/gitqlite/blame_test.go +++ b/pkg/gitqlite/blame_test.go @@ -50,11 +50,14 @@ func TestBlameDistinctFiles(t *testing.T) { if gotFileCount != expectedFileCount { t.Fatalf("expected %d distinct file paths in blame, got %d", expectedFileCount, gotFileCount) } + +} +func TestBlameContents(t *testing.T) { iterator, err := NewBlameIterator(fixtureRepo) if err != nil { t.Fatal(err) } - rows, err = fixtureDB.Query("SELECT contents from blame limit 100") + rows, err := fixtureDB.Query("SELECT contents from blame limit 100") if err != nil { t.Fatal(err) } From 2361e3218fc272a02ed34fee5e950c1c937ede44 Mon Sep 17 00:00:00 2001 From: vialeon Date: Mon, 18 Jan 2021 16:12:14 -0500 Subject: [PATCH 3/3] add commit_id and filename testing --- pkg/gitqlite/blame_test.go | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/pkg/gitqlite/blame_test.go b/pkg/gitqlite/blame_test.go index b23bd78b..868f06de 100644 --- a/pkg/gitqlite/blame_test.go +++ b/pkg/gitqlite/blame_test.go @@ -75,3 +75,49 @@ func TestBlameContents(t *testing.T) { } } } +func TestBlameCommitID(t *testing.T) { + iterator, err := NewBlameIterator(fixtureRepo) + if err != nil { + t.Fatal(err) + } + rows, err := fixtureDB.Query("SELECT commit_id from blame limit 100") + if err != nil { + t.Fatal(err) + } + _, lines, err := GetRowContents(rows) + if err != nil { + t.Fatal(err) + } + for _, line := range lines { + cont, err := iterator.Next() + if err != nil { + t.Fatal(err) + } + if !(line[0] == cont.CommitID) { + t.Fatalf("expected %s content in blame, got %s", cont.Content, line[0]) + } + } +} +func TestBlameFileNames(t *testing.T) { + iterator, err := NewBlameIterator(fixtureRepo) + if err != nil { + t.Fatal(err) + } + rows, err := fixtureDB.Query("SELECT path from blame limit 100") + if err != nil { + t.Fatal(err) + } + _, lines, err := GetRowContents(rows) + if err != nil { + t.Fatal(err) + } + for _, line := range lines { + cont, err := iterator.Next() + if err != nil { + t.Fatal(err) + } + if !(line[0] == cont.File) { + t.Fatalf("expected %s content in blame, got %s", cont.Content, line[0]) + } + } +}