Skip to content

Commit eda13d6

Browse files
committed
Combine branch tests to one for performance
1 parent 7bdd969 commit eda13d6

File tree

1 file changed

+33
-44
lines changed

1 file changed

+33
-44
lines changed

Diff for: tests/integration/compare_test.go

+33-44
Original file line numberDiff line numberDiff line change
@@ -62,70 +62,59 @@ func inspectCompare(t *testing.T, htmlDoc *HTMLDoc, diffCount int, diffChanges [
6262
// * c8e31bc (origin/add-csv) Add test csv file
6363
// * 808038d (HEAD -> master, origin/master, origin/HEAD) Added test links
6464

65-
// Inderect compare remove-files-b (head) with add-csv (base) branch
66-
//
67-
// 'link_hi' and 'test.csv' are deleted, 'test.txt' is added
6865
func TestCompareBranches(t *testing.T) {
6966
defer tests.PrepareTestEnv(t)()
7067

7168
session := loginUser(t, "user2")
69+
70+
// Inderect compare remove-files-b (head) with add-csv (base) branch
71+
//
72+
// 'link_hi' and 'test.csv' are deleted, 'test.txt' is added
7273
req := NewRequest(t, "GET", "/user2/repo20/compare/add-csv...remove-files-b")
7374
resp := session.MakeRequest(t, req, http.StatusOK)
7475
htmlDoc := NewHTMLParser(t, resp.Body)
7576

7677
diffCount := 3
77-
diffChanges := [3]string{"link_hi", "test.csv", "test.txt"}
78+
diffChanges := []string{"link_hi", "test.csv", "test.txt"}
7879

79-
inspectCompare(t, htmlDoc, diffCount, diffChanges[:])
80-
}
80+
inspectCompare(t, htmlDoc, diffCount, diffChanges)
8181

82-
// Inderect compare remove-files-b (head) with remove-files-a (base) branch
83-
//
84-
// 'link_hi' and 'test.csv' are deleted, 'test.txt' is added
85-
func TestCompareDeleted(t *testing.T) {
86-
defer tests.PrepareTestEnv(t)()
82+
// Inderect compare remove-files-b (head) with remove-files-a (base) branch
83+
//
84+
// 'link_hi' and 'test.csv' are deleted, 'test.txt' is added
8785

88-
session := loginUser(t, "user2")
89-
req := NewRequest(t, "GET", "/user2/repo20/compare/remove-files-a...remove-files-b")
90-
resp := session.MakeRequest(t, req, http.StatusOK)
91-
htmlDoc := NewHTMLParser(t, resp.Body)
86+
req = NewRequest(t, "GET", "/user2/repo20/compare/remove-files-a...remove-files-b")
87+
resp = session.MakeRequest(t, req, http.StatusOK)
88+
htmlDoc = NewHTMLParser(t, resp.Body)
9289

93-
diffCount := 3
94-
diffChanges := [3]string{"link_hi", "test.csv", "test.txt"}
90+
diffCount = 3
91+
diffChanges = []string{"link_hi", "test.csv", "test.txt"}
9592

96-
inspectCompare(t, htmlDoc, diffCount, diffChanges[:])
97-
}
93+
inspectCompare(t, htmlDoc, diffCount, diffChanges)
9894

99-
// Inderect compare remove-files-a (head) with remove-files-b (base) branch
100-
//
101-
// 'link_hi' and 'test.csv' are deleted
102-
func TestCompareDeletedReverse(t *testing.T) {
103-
defer tests.PrepareTestEnv(t)()
95+
// Inderect compare remove-files-a (head) with remove-files-b (base) branch
96+
//
97+
// 'link_hi' and 'test.csv' are deleted
10498

105-
session := loginUser(t, "user2")
106-
req := NewRequest(t, "GET", "/user2/repo20/compare/remove-files-b...remove-files-a")
107-
resp := session.MakeRequest(t, req, http.StatusOK)
108-
htmlDoc := NewHTMLParser(t, resp.Body)
99+
req = NewRequest(t, "GET", "/user2/repo20/compare/remove-files-b...remove-files-a")
100+
resp = session.MakeRequest(t, req, http.StatusOK)
101+
htmlDoc = NewHTMLParser(t, resp.Body)
109102

110-
diffCount := 2
111-
diffChanges := [2]string{"link_hi", "test.csv"}
103+
diffCount = 2
104+
diffChanges = []string{"link_hi", "test.csv"}
112105

113-
inspectCompare(t, htmlDoc, diffCount, diffChanges[:])
114-
}
106+
inspectCompare(t, htmlDoc, diffCount, diffChanges)
115107

116-
// Direct compare remove-files-b (head) with remove-files-a (base) branch
117-
//
118-
// 'test.txt' is deleted
119-
func TestDirectCompareDeleted(t *testing.T) {
120-
defer tests.PrepareTestEnv(t)()
108+
// Direct compare remove-files-b (head) with remove-files-a (base) branch
109+
//
110+
// 'test.txt' is deleted
121111

122-
session := loginUser(t, "user2")
123-
req := NewRequest(t, "GET", "/user2/repo20/compare/remove-files-b..remove-files-a")
124-
resp := session.MakeRequest(t, req, http.StatusOK)
125-
htmlDoc := NewHTMLParser(t, resp.Body)
112+
req = NewRequest(t, "GET", "/user2/repo20/compare/remove-files-b..remove-files-a")
113+
resp = session.MakeRequest(t, req, http.StatusOK)
114+
htmlDoc = NewHTMLParser(t, resp.Body)
126115

127-
diffCount := 1
128-
diffChanges := [1]string{"test.txt"}
116+
diffCount = 1
117+
diffChanges = []string{"test.txt"}
129118

130-
inspectCompare(t, htmlDoc, diffCount, diffChanges[:])
119+
inspectCompare(t, htmlDoc, diffCount, diffChanges)
131120
}

0 commit comments

Comments
 (0)