Skip to content

Commit

Permalink
Combine branch tests to one for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
kdumontnu committed Feb 19, 2023
1 parent 7bdd969 commit eda13d6
Showing 1 changed file with 33 additions and 44 deletions.
77 changes: 33 additions & 44 deletions tests/integration/compare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit eda13d6

Please sign in to comment.