Fix tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
6994c8ce05
commit
b4268e6bab
4 changed files with 18 additions and 25 deletions
|
|
@ -219,14 +219,6 @@ func (s *EnterpriseTestSuite) TestCreateEnterpriseInvalidDBPassphrase() {
|
|||
|
||||
func (s *EnterpriseTestSuite) TestCreateEnterpriseDBCreateErr() {
|
||||
s.Fixtures.SQLMock.ExpectBegin()
|
||||
s.Fixtures.SQLMock.
|
||||
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 ?")).
|
||||
WithArgs(s.adminUserID, s.Fixtures.Enterprises[0].CredentialsName, 1).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"id", "endpoint_name"}).AddRow(s.testCreds.ID, s.testCreds.Endpoint.Name))
|
||||
s.Fixtures.SQLMock.ExpectQuery(regexp.QuoteMeta("SELECT * FROM `github_endpoints` WHERE `github_endpoints`.`name` = ? AND `github_endpoints`.`deleted_at` IS NULL")).
|
||||
WithArgs(s.testCreds.Endpoint.Name).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"name"}).
|
||||
AddRow(s.testCreds.Endpoint.Name))
|
||||
s.Fixtures.SQLMock.
|
||||
ExpectExec(regexp.QuoteMeta("INSERT INTO `enterprises`")).
|
||||
WillReturnError(fmt.Errorf("creating enterprise mock error"))
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ func (s *GiteaTestSuite) TestCreatingEndpoint() {
|
|||
ctx := garmTesting.ImpersonateAdminContext(context.Background(), s.db, s.T())
|
||||
|
||||
createEpParams := params.CreateGiteaEndpointParams{
|
||||
Name: testEndpointName,
|
||||
Name: alternetTestEndpointName,
|
||||
Description: testEndpointDescription,
|
||||
APIBaseURL: testAPIBaseURL,
|
||||
BaseURL: testBaseURL,
|
||||
|
|
@ -70,14 +70,14 @@ func (s *GiteaTestSuite) TestCreatingEndpoint() {
|
|||
endpoint, err := s.db.CreateGiteaEndpoint(ctx, createEpParams)
|
||||
s.Require().NoError(err)
|
||||
s.Require().NotNil(endpoint)
|
||||
s.Require().Equal(testEndpointName, endpoint.Name)
|
||||
s.Require().Equal(alternetTestEndpointName, endpoint.Name)
|
||||
}
|
||||
|
||||
func (s *GiteaTestSuite) TestCreatingDuplicateEndpointFails() {
|
||||
ctx := garmTesting.ImpersonateAdminContext(context.Background(), s.db, s.T())
|
||||
|
||||
createEpParams := params.CreateGiteaEndpointParams{
|
||||
Name: testEndpointName,
|
||||
Name: alternetTestEndpointName,
|
||||
Description: testEndpointDescription,
|
||||
APIBaseURL: testAPIBaseURL,
|
||||
BaseURL: testBaseURL,
|
||||
|
|
@ -95,7 +95,7 @@ func (s *GiteaTestSuite) TestGetEndpoint() {
|
|||
ctx := garmTesting.ImpersonateAdminContext(context.Background(), s.db, s.T())
|
||||
|
||||
createEpParams := params.CreateGiteaEndpointParams{
|
||||
Name: "deleteme",
|
||||
Name: alternetTestEndpointName,
|
||||
Description: testEndpointDescription,
|
||||
APIBaseURL: testAPIBaseURL,
|
||||
BaseURL: testBaseURL,
|
||||
|
|
@ -129,7 +129,7 @@ func (s *GiteaTestSuite) TestDeletingEndpoint() {
|
|||
ctx := garmTesting.ImpersonateAdminContext(context.Background(), s.db, s.T())
|
||||
|
||||
createEpParams := params.CreateGiteaEndpointParams{
|
||||
Name: testEndpointName,
|
||||
Name: alternetTestEndpointName,
|
||||
Description: testEndpointDescription,
|
||||
APIBaseURL: testAPIBaseURL,
|
||||
BaseURL: testBaseURL,
|
||||
|
|
@ -139,10 +139,10 @@ func (s *GiteaTestSuite) TestDeletingEndpoint() {
|
|||
s.Require().NoError(err)
|
||||
s.Require().NotNil(endpoint)
|
||||
|
||||
err = s.db.DeleteGiteaEndpoint(ctx, testEndpointName)
|
||||
err = s.db.DeleteGiteaEndpoint(ctx, alternetTestEndpointName)
|
||||
s.Require().NoError(err)
|
||||
|
||||
_, err = s.db.GetGiteaEndpoint(ctx, testEndpointName)
|
||||
_, err = s.db.GetGiteaEndpoint(ctx, alternetTestEndpointName)
|
||||
s.Require().Error(err)
|
||||
s.Require().ErrorIs(err, runnerErrors.ErrNotFound)
|
||||
}
|
||||
|
|
@ -199,7 +199,7 @@ func (s *GiteaTestSuite) TestListEndpoints() {
|
|||
ctx := garmTesting.ImpersonateAdminContext(context.Background(), s.db, s.T())
|
||||
|
||||
createEpParams := params.CreateGiteaEndpointParams{
|
||||
Name: testEndpointName,
|
||||
Name: alternetTestEndpointName,
|
||||
Description: testEndpointDescription,
|
||||
APIBaseURL: testAPIBaseURL,
|
||||
BaseURL: testBaseURL,
|
||||
|
|
@ -210,7 +210,7 @@ func (s *GiteaTestSuite) TestListEndpoints() {
|
|||
|
||||
endpoints, err := s.db.ListGiteaEndpoints(ctx)
|
||||
s.Require().NoError(err)
|
||||
s.Require().Len(endpoints, 1)
|
||||
s.Require().Len(endpoints, 2)
|
||||
}
|
||||
|
||||
func (s *GiteaTestSuite) TestCreateCredentialsFailsWithUnauthorizedForAnonUser() {
|
||||
|
|
|
|||
|
|
@ -33,13 +33,14 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
testUploadBaseURL string = "https://uploads.example.com"
|
||||
testBaseURL string = "https://example.com"
|
||||
testAPIBaseURL string = "https://api.example.com"
|
||||
testEndpointName string = "test-endpoint"
|
||||
testEndpointDescription string = "test description"
|
||||
testCredsName string = "test-creds"
|
||||
testCredsDescription string = "test creds"
|
||||
testUploadBaseURL string = "https://uploads.example.com"
|
||||
testBaseURL string = "https://example.com"
|
||||
testAPIBaseURL string = "https://api.example.com"
|
||||
testEndpointName string = "test-endpoint"
|
||||
alternetTestEndpointName string = "test-endpoint-alternate"
|
||||
testEndpointDescription string = "test description"
|
||||
testCredsName string = "test-creds"
|
||||
testCredsDescription string = "test creds"
|
||||
)
|
||||
|
||||
type GithubTestSuite struct {
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ func (s *RepoTestSuite) TestCreateRepository() {
|
|||
|
||||
entity, err := repo.GetEntity()
|
||||
s.Require().Nil(err)
|
||||
s.Require().Equal(s.Fixtures.CreateRepoParams.Owner, entity.ID)
|
||||
s.Require().Equal(s.Fixtures.CreateRepoParams.Owner, entity.Owner)
|
||||
s.Require().Equal(entity.EntityType, params.ForgeEntityTypeRepository)
|
||||
|
||||
forgeType, err := entity.GetForgeType()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue