From eda13d61dab1ce06a1163bc7ed1c9087170c7d37 Mon Sep 17 00:00:00 2001 From: Kyle D Date: Sun, 19 Feb 2023 16:55:48 -0500 Subject: [PATCH] Combine branch tests to one for performance --- tests/integration/compare_test.go | 77 +++++++++++++------------------ 1 file changed, 33 insertions(+), 44 deletions(-) diff --git a/tests/integration/compare_test.go b/tests/integration/compare_test.go index f5323d0c7fa0b..509524ca5627c 100644 --- a/tests/integration/compare_test.go +++ b/tests/integration/compare_test.go @@ -62,70 +62,59 @@ func inspectCompare(t *testing.T, htmlDoc *HTMLDoc, diffCount int, diffChanges [ // * c8e31bc (origin/add-csv) Add test csv file // * 808038d (HEAD -> master, origin/master, origin/HEAD) Added test links -// Inderect compare remove-files-b (head) with add-csv (base) branch -// -// 'link_hi' and 'test.csv' are deleted, 'test.txt' is added func TestCompareBranches(t *testing.T) { defer tests.PrepareTestEnv(t)() session := loginUser(t, "user2") + + // Inderect compare remove-files-b (head) with add-csv (base) branch + // + // 'link_hi' and 'test.csv' are deleted, 'test.txt' is added req := NewRequest(t, "GET", "/user2/repo20/compare/add-csv...remove-files-b") resp := session.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) diffCount := 3 - diffChanges := [3]string{"link_hi", "test.csv", "test.txt"} + diffChanges := []string{"link_hi", "test.csv", "test.txt"} - inspectCompare(t, htmlDoc, diffCount, diffChanges[:]) -} + inspectCompare(t, htmlDoc, diffCount, diffChanges) -// Inderect compare remove-files-b (head) with remove-files-a (base) branch -// -// 'link_hi' and 'test.csv' are deleted, 'test.txt' is added -func TestCompareDeleted(t *testing.T) { - defer tests.PrepareTestEnv(t)() + // Inderect compare remove-files-b (head) with remove-files-a (base) branch + // + // 'link_hi' and 'test.csv' are deleted, 'test.txt' is added - session := loginUser(t, "user2") - req := NewRequest(t, "GET", "/user2/repo20/compare/remove-files-a...remove-files-b") - resp := session.MakeRequest(t, req, http.StatusOK) - htmlDoc := NewHTMLParser(t, resp.Body) + req = NewRequest(t, "GET", "/user2/repo20/compare/remove-files-a...remove-files-b") + resp = session.MakeRequest(t, req, http.StatusOK) + htmlDoc = NewHTMLParser(t, resp.Body) - diffCount := 3 - diffChanges := [3]string{"link_hi", "test.csv", "test.txt"} + diffCount = 3 + diffChanges = []string{"link_hi", "test.csv", "test.txt"} - inspectCompare(t, htmlDoc, diffCount, diffChanges[:]) -} + inspectCompare(t, htmlDoc, diffCount, diffChanges) -// Inderect compare remove-files-a (head) with remove-files-b (base) branch -// -// 'link_hi' and 'test.csv' are deleted -func TestCompareDeletedReverse(t *testing.T) { - defer tests.PrepareTestEnv(t)() + // Inderect compare remove-files-a (head) with remove-files-b (base) branch + // + // 'link_hi' and 'test.csv' are deleted - session := loginUser(t, "user2") - req := NewRequest(t, "GET", "/user2/repo20/compare/remove-files-b...remove-files-a") - resp := session.MakeRequest(t, req, http.StatusOK) - htmlDoc := NewHTMLParser(t, resp.Body) + req = NewRequest(t, "GET", "/user2/repo20/compare/remove-files-b...remove-files-a") + resp = session.MakeRequest(t, req, http.StatusOK) + htmlDoc = NewHTMLParser(t, resp.Body) - diffCount := 2 - diffChanges := [2]string{"link_hi", "test.csv"} + diffCount = 2 + diffChanges = []string{"link_hi", "test.csv"} - inspectCompare(t, htmlDoc, diffCount, diffChanges[:]) -} + inspectCompare(t, htmlDoc, diffCount, diffChanges) -// Direct compare remove-files-b (head) with remove-files-a (base) branch -// -// 'test.txt' is deleted -func TestDirectCompareDeleted(t *testing.T) { - defer tests.PrepareTestEnv(t)() + // Direct compare remove-files-b (head) with remove-files-a (base) branch + // + // 'test.txt' is deleted - session := loginUser(t, "user2") - req := NewRequest(t, "GET", "/user2/repo20/compare/remove-files-b..remove-files-a") - resp := session.MakeRequest(t, req, http.StatusOK) - htmlDoc := NewHTMLParser(t, resp.Body) + req = NewRequest(t, "GET", "/user2/repo20/compare/remove-files-b..remove-files-a") + resp = session.MakeRequest(t, req, http.StatusOK) + htmlDoc = NewHTMLParser(t, resp.Body) - diffCount := 1 - diffChanges := [1]string{"test.txt"} + diffCount = 1 + diffChanges = []string{"test.txt"} - inspectCompare(t, htmlDoc, diffCount, diffChanges[:]) + inspectCompare(t, htmlDoc, diffCount, diffChanges) }