Skip to content

Commit b4268e6

Browse files
Fix tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
1 parent 6994c8c commit b4268e6

File tree

4 files changed

+18
-25
lines changed

4 files changed

+18
-25
lines changed

database/sql/enterprise_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,6 @@ func (s *EnterpriseTestSuite) TestCreateEnterpriseInvalidDBPassphrase() {
219219

220220
func (s *EnterpriseTestSuite) TestCreateEnterpriseDBCreateErr() {
221221
s.Fixtures.SQLMock.ExpectBegin()
222-
s.Fixtures.SQLMock.
223-
ExpectQuery(regexp.QuoteMeta("SELECT * FROM `github_credentials` WHERE user_id = ? AND name = ? AND `github_credentials`.`deleted_at` IS NULL ORDER BY `github_credentials`.`id` LIMIT ?")).
224-
WithArgs(s.adminUserID, s.Fixtures.Enterprises[0].CredentialsName, 1).
225-
WillReturnRows(sqlmock.NewRows([]string{"id", "endpoint_name"}).AddRow(s.testCreds.ID, s.testCreds.Endpoint.Name))
226-
s.Fixtures.SQLMock.ExpectQuery(regexp.QuoteMeta("SELECT * FROM `github_endpoints` WHERE `github_endpoints`.`name` = ? AND `github_endpoints`.`deleted_at` IS NULL")).
227-
WithArgs(s.testCreds.Endpoint.Name).
228-
WillReturnRows(sqlmock.NewRows([]string{"name"}).
229-
AddRow(s.testCreds.Endpoint.Name))
230222
s.Fixtures.SQLMock.
231223
ExpectExec(regexp.QuoteMeta("INSERT INTO `enterprises`")).
232224
WillReturnError(fmt.Errorf("creating enterprise mock error"))

database/sql/gitea_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (s *GiteaTestSuite) TestCreatingEndpoint() {
6161
ctx := garmTesting.ImpersonateAdminContext(context.Background(), s.db, s.T())
6262

6363
createEpParams := params.CreateGiteaEndpointParams{
64-
Name: testEndpointName,
64+
Name: alternetTestEndpointName,
6565
Description: testEndpointDescription,
6666
APIBaseURL: testAPIBaseURL,
6767
BaseURL: testBaseURL,
@@ -70,14 +70,14 @@ func (s *GiteaTestSuite) TestCreatingEndpoint() {
7070
endpoint, err := s.db.CreateGiteaEndpoint(ctx, createEpParams)
7171
s.Require().NoError(err)
7272
s.Require().NotNil(endpoint)
73-
s.Require().Equal(testEndpointName, endpoint.Name)
73+
s.Require().Equal(alternetTestEndpointName, endpoint.Name)
7474
}
7575

7676
func (s *GiteaTestSuite) TestCreatingDuplicateEndpointFails() {
7777
ctx := garmTesting.ImpersonateAdminContext(context.Background(), s.db, s.T())
7878

7979
createEpParams := params.CreateGiteaEndpointParams{
80-
Name: testEndpointName,
80+
Name: alternetTestEndpointName,
8181
Description: testEndpointDescription,
8282
APIBaseURL: testAPIBaseURL,
8383
BaseURL: testBaseURL,
@@ -95,7 +95,7 @@ func (s *GiteaTestSuite) TestGetEndpoint() {
9595
ctx := garmTesting.ImpersonateAdminContext(context.Background(), s.db, s.T())
9696

9797
createEpParams := params.CreateGiteaEndpointParams{
98-
Name: "deleteme",
98+
Name: alternetTestEndpointName,
9999
Description: testEndpointDescription,
100100
APIBaseURL: testAPIBaseURL,
101101
BaseURL: testBaseURL,
@@ -129,7 +129,7 @@ func (s *GiteaTestSuite) TestDeletingEndpoint() {
129129
ctx := garmTesting.ImpersonateAdminContext(context.Background(), s.db, s.T())
130130

131131
createEpParams := params.CreateGiteaEndpointParams{
132-
Name: testEndpointName,
132+
Name: alternetTestEndpointName,
133133
Description: testEndpointDescription,
134134
APIBaseURL: testAPIBaseURL,
135135
BaseURL: testBaseURL,
@@ -139,10 +139,10 @@ func (s *GiteaTestSuite) TestDeletingEndpoint() {
139139
s.Require().NoError(err)
140140
s.Require().NotNil(endpoint)
141141

142-
err = s.db.DeleteGiteaEndpoint(ctx, testEndpointName)
142+
err = s.db.DeleteGiteaEndpoint(ctx, alternetTestEndpointName)
143143
s.Require().NoError(err)
144144

145-
_, err = s.db.GetGiteaEndpoint(ctx, testEndpointName)
145+
_, err = s.db.GetGiteaEndpoint(ctx, alternetTestEndpointName)
146146
s.Require().Error(err)
147147
s.Require().ErrorIs(err, runnerErrors.ErrNotFound)
148148
}
@@ -199,7 +199,7 @@ func (s *GiteaTestSuite) TestListEndpoints() {
199199
ctx := garmTesting.ImpersonateAdminContext(context.Background(), s.db, s.T())
200200

201201
createEpParams := params.CreateGiteaEndpointParams{
202-
Name: testEndpointName,
202+
Name: alternetTestEndpointName,
203203
Description: testEndpointDescription,
204204
APIBaseURL: testAPIBaseURL,
205205
BaseURL: testBaseURL,
@@ -210,7 +210,7 @@ func (s *GiteaTestSuite) TestListEndpoints() {
210210

211211
endpoints, err := s.db.ListGiteaEndpoints(ctx)
212212
s.Require().NoError(err)
213-
s.Require().Len(endpoints, 1)
213+
s.Require().Len(endpoints, 2)
214214
}
215215

216216
func (s *GiteaTestSuite) TestCreateCredentialsFailsWithUnauthorizedForAnonUser() {

database/sql/github_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ import (
3333
)
3434

3535
const (
36-
testUploadBaseURL string = "https://uploads.example.com"
37-
testBaseURL string = "https://example.com"
38-
testAPIBaseURL string = "https://api.example.com"
39-
testEndpointName string = "test-endpoint"
40-
testEndpointDescription string = "test description"
41-
testCredsName string = "test-creds"
42-
testCredsDescription string = "test creds"
36+
testUploadBaseURL string = "https://uploads.example.com"
37+
testBaseURL string = "https://example.com"
38+
testAPIBaseURL string = "https://api.example.com"
39+
testEndpointName string = "test-endpoint"
40+
alternetTestEndpointName string = "test-endpoint-alternate"
41+
testEndpointDescription string = "test description"
42+
testCredsName string = "test-creds"
43+
testCredsDescription string = "test creds"
4344
)
4445

4546
type GithubTestSuite struct {

database/sql/repositories_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func (s *RepoTestSuite) TestCreateRepository() {
226226

227227
entity, err := repo.GetEntity()
228228
s.Require().Nil(err)
229-
s.Require().Equal(s.Fixtures.CreateRepoParams.Owner, entity.ID)
229+
s.Require().Equal(s.Fixtures.CreateRepoParams.Owner, entity.Owner)
230230
s.Require().Equal(entity.EntityType, params.ForgeEntityTypeRepository)
231231

232232
forgeType, err := entity.GetForgeType()

0 commit comments

Comments
 (0)