Skip to content

Commit 3101e90

Browse files
committed
Remove tests
1 parent 5cce3a7 commit 3101e90

File tree

2 files changed

+4
-314
lines changed

2 files changed

+4
-314
lines changed

integrations/api_repo_test.go

Lines changed: 0 additions & 214 deletions
Original file line numberDiff line numberDiff line change
@@ -46,220 +46,6 @@ func TestAPISearchRepoNotLogin(t *testing.T) {
4646
assert.Contains(t, repo.Name, keyword)
4747
assert.False(t, repo.Private)
4848
}
49-
50-
// Should return all (max 50) public repositories
51-
req = NewRequest(t, "GET", "/api/v1/repos/search?limit=50")
52-
resp = MakeRequest(t, req, http.StatusOK)
53-
54-
DecodeJSON(t, resp, &body)
55-
assert.Len(t, body.Data, 12)
56-
for _, repo := range body.Data {
57-
assert.NotEmpty(t, repo.Name)
58-
assert.False(t, repo.Private)
59-
}
60-
61-
// Should return (max 10) public repositories
62-
req = NewRequest(t, "GET", "/api/v1/repos/search?limit=10")
63-
resp = MakeRequest(t, req, http.StatusOK)
64-
65-
DecodeJSON(t, resp, &body)
66-
assert.Len(t, body.Data, 10)
67-
for _, repo := range body.Data {
68-
assert.NotEmpty(t, repo.Name)
69-
assert.False(t, repo.Private)
70-
}
71-
72-
const keyword2 = "big_test_"
73-
// Should return all public repositories which (partial) match keyword
74-
req = NewRequestf(t, "GET", "/api/v1/repos/search?q=%s", keyword2)
75-
resp = MakeRequest(t, req, http.StatusOK)
76-
77-
DecodeJSON(t, resp, &body)
78-
assert.Len(t, body.Data, 4)
79-
for _, repo := range body.Data {
80-
assert.Contains(t, repo.Name, keyword2)
81-
assert.False(t, repo.Private)
82-
}
83-
84-
// Should return all public repositories accessible and related to user
85-
const userID = int64(15)
86-
req = NewRequestf(t, "GET", "/api/v1/repos/search?uid=%d", userID)
87-
resp = MakeRequest(t, req, http.StatusOK)
88-
89-
DecodeJSON(t, resp, &body)
90-
assert.Len(t, body.Data, 4)
91-
for _, repo := range body.Data {
92-
assert.NotEmpty(t, repo.Name)
93-
assert.False(t, repo.Private)
94-
}
95-
96-
// Should return all public repositories accessible and related to user
97-
const user2ID = int64(16)
98-
req = NewRequestf(t, "GET", "/api/v1/repos/search?uid=%d", user2ID)
99-
resp = MakeRequest(t, req, http.StatusOK)
100-
101-
DecodeJSON(t, resp, &body)
102-
assert.Len(t, body.Data, 1)
103-
for _, repo := range body.Data {
104-
assert.NotEmpty(t, repo.Name)
105-
assert.False(t, repo.Private)
106-
}
107-
108-
// Should return all public repositories owned by organization
109-
const orgID = int64(17)
110-
req = NewRequestf(t, "GET", "/api/v1/repos/search?uid=%d", orgID)
111-
resp = MakeRequest(t, req, http.StatusOK)
112-
113-
DecodeJSON(t, resp, &body)
114-
assert.Len(t, body.Data, 1)
115-
for _, repo := range body.Data {
116-
assert.NotEmpty(t, repo.Name)
117-
assert.Equal(t, repo.Owner.ID, orgID)
118-
assert.False(t, repo.Private)
119-
}
120-
}
121-
122-
func TestAPISearchRepoLoggedUser(t *testing.T) {
123-
prepareTestEnv(t)
124-
125-
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 15}).(*models.User)
126-
user2 := models.AssertExistsAndLoadBean(t, &models.User{ID: 16}).(*models.User)
127-
session := loginUser(t, user.Name)
128-
session2 := loginUser(t, user2.Name)
129-
130-
var body api.SearchResults
131-
132-
// Get public repositories accessible and not related to logged in user that match the keyword
133-
// Should return all public repositories which (partial) match keyword
134-
const keyword = "big_test_"
135-
req := NewRequestf(t, "GET", "/api/v1/repos/search?q=%s", keyword)
136-
resp := session.MakeRequest(t, req, http.StatusOK)
137-
138-
DecodeJSON(t, resp, &body)
139-
assert.Len(t, body.Data, 4)
140-
for _, repo := range body.Data {
141-
assert.Contains(t, repo.Name, keyword)
142-
assert.False(t, repo.Private)
143-
}
144-
// Test when user2 is logged in
145-
resp = session2.MakeRequest(t, req, http.StatusOK)
146-
147-
DecodeJSON(t, resp, &body)
148-
assert.Len(t, body.Data, 4)
149-
for _, repo := range body.Data {
150-
assert.Contains(t, repo.Name, keyword)
151-
assert.False(t, repo.Private)
152-
}
153-
154-
// Get all public repositories accessible and not related to logged in user
155-
// Should return all (max 50) public repositories
156-
req = NewRequest(t, "GET", "/api/v1/repos/search?limit=50")
157-
resp = session.MakeRequest(t, req, http.StatusOK)
158-
159-
DecodeJSON(t, resp, &body)
160-
assert.Len(t, body.Data, 12)
161-
for _, repo := range body.Data {
162-
assert.NotEmpty(t, repo.Name)
163-
assert.False(t, repo.Private)
164-
}
165-
// Test when user2 is logged in
166-
resp = session2.MakeRequest(t, req, http.StatusOK)
167-
168-
DecodeJSON(t, resp, &body)
169-
assert.Len(t, body.Data, 12)
170-
for _, repo := range body.Data {
171-
assert.NotEmpty(t, repo.Name)
172-
assert.False(t, repo.Private)
173-
}
174-
175-
// Get all public repositories accessible and not related to logged in user
176-
// Should return all (max 10) public repositories
177-
req = NewRequest(t, "GET", "/api/v1/repos/search?limit=10")
178-
resp = session.MakeRequest(t, req, http.StatusOK)
179-
180-
DecodeJSON(t, resp, &body)
181-
assert.Len(t, body.Data, 10)
182-
for _, repo := range body.Data {
183-
assert.NotEmpty(t, repo.Name)
184-
assert.False(t, repo.Private)
185-
}
186-
// Test when user2 is logged in
187-
resp = session2.MakeRequest(t, req, http.StatusOK)
188-
189-
DecodeJSON(t, resp, &body)
190-
assert.Len(t, body.Data, 10)
191-
for _, repo := range body.Data {
192-
assert.NotEmpty(t, repo.Name)
193-
assert.False(t, repo.Private)
194-
}
195-
196-
// Get repositories of logged in user
197-
// Should return all public and private repositories accessible and related to user
198-
req = NewRequestf(t, "GET", "/api/v1/repos/search?uid=%d", user.ID)
199-
resp = session.MakeRequest(t, req, http.StatusOK)
200-
201-
DecodeJSON(t, resp, &body)
202-
assert.Len(t, body.Data, 8)
203-
for _, repo := range body.Data {
204-
assert.NotEmpty(t, repo.Name)
205-
}
206-
// Test when user2 is logged in
207-
req = NewRequestf(t, "GET", "/api/v1/repos/search?uid=%d", user2.ID)
208-
resp = session2.MakeRequest(t, req, http.StatusOK)
209-
210-
DecodeJSON(t, resp, &body)
211-
assert.Len(t, body.Data, 2)
212-
for _, repo := range body.Data {
213-
assert.NotEmpty(t, repo.Name)
214-
}
215-
216-
// Get repositories of another user
217-
// Should return all public repositories accessible and related to user
218-
req = NewRequestf(t, "GET", "/api/v1/repos/search?uid=%d", user2.ID)
219-
resp = session.MakeRequest(t, req, http.StatusOK)
220-
221-
DecodeJSON(t, resp, &body)
222-
assert.Len(t, body.Data, 1)
223-
for _, repo := range body.Data {
224-
assert.NotEmpty(t, repo.Name)
225-
assert.False(t, repo.Private)
226-
}
227-
// Test when user2 is logged in
228-
req = NewRequestf(t, "GET", "/api/v1/repos/search?uid=%d", user.ID)
229-
resp = session2.MakeRequest(t, req, http.StatusOK)
230-
231-
DecodeJSON(t, resp, &body)
232-
assert.Len(t, body.Data, 4)
233-
for _, repo := range body.Data {
234-
assert.NotEmpty(t, repo.Name)
235-
assert.False(t, repo.Private)
236-
}
237-
238-
// Get repositories of organization owned by logged in user
239-
// Should return all public and private repositories owned by organization
240-
const orgID = int64(17)
241-
req = NewRequestf(t, "GET", "/api/v1/repos/search?uid=%d", orgID)
242-
resp = session.MakeRequest(t, req, http.StatusOK)
243-
244-
DecodeJSON(t, resp, &body)
245-
assert.Len(t, body.Data, 2)
246-
for _, repo := range body.Data {
247-
assert.NotEmpty(t, repo.Name)
248-
assert.Equal(t, repo.Owner.ID, orgID)
249-
}
250-
251-
// Get repositories of organization owned by another user
252-
// Should return all public repositories owned by organization
253-
req = NewRequestf(t, "GET", "/api/v1/repos/search?uid=%d", orgID)
254-
resp = session2.MakeRequest(t, req, http.StatusOK)
255-
256-
DecodeJSON(t, resp, &body)
257-
assert.Len(t, body.Data, 1)
258-
for _, repo := range body.Data {
259-
assert.NotEmpty(t, repo.Name)
260-
assert.Equal(t, repo.Owner.ID, orgID)
261-
assert.False(t, repo.Private)
262-
}
26349
}
26450

26551
func TestAPIViewRepo(t *testing.T) {

models/repo_list_test.go

Lines changed: 4 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func TestSearchRepositoryByName(t *testing.T) {
1818
Keyword: "repo_12",
1919
Page: 1,
2020
PageSize: 10,
21+
Searcher: nil,
2122
})
2223

2324
assert.NotNil(t, repos)
@@ -31,6 +32,7 @@ func TestSearchRepositoryByName(t *testing.T) {
3132
Keyword: "test_repo",
3233
Page: 1,
3334
PageSize: 10,
35+
Searcher: nil,
3436
})
3537

3638
assert.NotNil(t, repos)
@@ -43,6 +45,7 @@ func TestSearchRepositoryByName(t *testing.T) {
4345
Page: 1,
4446
PageSize: 10,
4547
Private: true,
48+
Searcher: &User{ID: 14},
4649
})
4750

4851
assert.NotNil(t, repos)
@@ -57,109 +60,10 @@ func TestSearchRepositoryByName(t *testing.T) {
5760
Page: 1,
5861
PageSize: 10,
5962
Private: true,
63+
Searcher: &User{ID: 14},
6064
})
6165

6266
assert.NotNil(t, repos)
6367
assert.NoError(t, err)
6468
assert.Equal(t, int64(3), count)
65-
66-
// Get all public repositories by name
67-
repos, count, err = SearchRepositoryByName(&SearchRepoOptions{
68-
Keyword: "big_test_",
69-
Page: 1,
70-
PageSize: 10,
71-
})
72-
73-
assert.NotNil(t, repos)
74-
assert.NoError(t, err)
75-
assert.Equal(t, int64(4), count)
76-
77-
// Get all public + private repositories by name
78-
repos, count, err = SearchRepositoryByName(&SearchRepoOptions{
79-
Keyword: "big_test_",
80-
Page: 1,
81-
PageSize: 10,
82-
Private: true,
83-
})
84-
85-
assert.NotNil(t, repos)
86-
assert.NoError(t, err)
87-
assert.Equal(t, int64(8), count)
88-
89-
// Get all public repositories of user
90-
repos, count, err = SearchRepositoryByName(&SearchRepoOptions{
91-
Page: 1,
92-
PageSize: 10,
93-
OwnerID: 15,
94-
Searcher: &User{ID: 15},
95-
})
96-
97-
assert.NotNil(t, repos)
98-
assert.NoError(t, err)
99-
assert.Equal(t, int64(3), count)
100-
101-
// Get all public + private repositories of user
102-
repos, count, err = SearchRepositoryByName(&SearchRepoOptions{
103-
Page: 1,
104-
PageSize: 10,
105-
OwnerID: 15,
106-
Private: true,
107-
Searcher: &User{ID: 15},
108-
})
109-
110-
assert.NotNil(t, repos)
111-
assert.NoError(t, err)
112-
assert.Equal(t, int64(6), count)
113-
114-
// Get all public (including collaborative) repositories of user
115-
repos, count, err = SearchRepositoryByName(&SearchRepoOptions{
116-
Page: 1,
117-
PageSize: 10,
118-
OwnerID: 15,
119-
Collaborate: true,
120-
Searcher: &User{ID: 15},
121-
})
122-
123-
assert.NotNil(t, repos)
124-
assert.NoError(t, err)
125-
assert.Equal(t, int64(4), count)
126-
127-
// Get all public + private (including collaborative) repositories of user
128-
repos, count, err = SearchRepositoryByName(&SearchRepoOptions{
129-
Page: 1,
130-
PageSize: 10,
131-
OwnerID: 15,
132-
Private: true,
133-
Collaborate: true,
134-
Searcher: &User{ID: 15},
135-
})
136-
137-
assert.NotNil(t, repos)
138-
assert.NoError(t, err)
139-
assert.Equal(t, int64(8), count)
140-
141-
// Get all public repositories of organization
142-
repos, count, err = SearchRepositoryByName(&SearchRepoOptions{
143-
Page: 1,
144-
PageSize: 10,
145-
OwnerID: 17,
146-
Searcher: &User{ID: 17},
147-
})
148-
149-
assert.NotNil(t, repos)
150-
assert.NoError(t, err)
151-
assert.Equal(t, int64(1), count)
152-
153-
// Get all public + private repositories of organization
154-
repos, count, err = SearchRepositoryByName(&SearchRepoOptions{
155-
Page: 1,
156-
PageSize: 10,
157-
OwnerID: 17,
158-
Private: true,
159-
Searcher: &User{ID: 17},
160-
})
161-
162-
assert.NotNil(t, repos)
163-
assert.NoError(t, err)
164-
assert.Equal(t, int64(2), count)
16569
}

0 commit comments

Comments
 (0)