Skip to content

Commit a458e1e

Browse files
patrick.rissmann@l3montree.compatrick.rissmann@l3montree.com
authored andcommitted
Had to change the tests aswell after changing the list function
1 parent 241175f commit a458e1e

5 files changed

Lines changed: 22 additions & 16 deletions

File tree

internal/core/attestation/attestation_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (a *attestationController) List(ctx core.Context) error {
2424
asset := core.GetAsset(ctx)
2525
assetVersion := core.GetAssetVersion(ctx)
2626

27-
attestationList, err := a.attestationRepository.GetByAssetVersion(asset.GetID(), assetVersion.Name)
27+
attestationList, err := a.attestationRepository.GetByAssetVersionAndAssetID(asset.GetID(), assetVersion.Name)
2828
if err != nil {
2929
return err
3030
}

internal/core/attestation/attestation_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ func TestList(t *testing.T) {
2121
ctx := e.NewContext(req, httptest.NewRecorder())
2222

2323
asset := models.Asset{}
24+
assetVersion := models.AssetVersion{}
25+
2426
core.SetAsset(ctx, asset)
27+
core.SetAssetVersion(ctx, assetVersion)
2528

2629
attestationRepository := mocks.NewCoreAttestationRepository(t)
27-
attestationRepository.On("GetByAssetID", mock.Anything).Return([]models.Attestation{
30+
attestationRepository.On("GetByAssetVersionAndAssetID", mock.Anything, mock.Anything).Return([]models.Attestation{
2831
{AttestationName: "not ocol name"},
2932
}, nil)
3033
attestationController := attestation.NewAttestationController(attestationRepository)
@@ -40,10 +43,13 @@ func TestList(t *testing.T) {
4043
ctx := e.NewContext(req, httptest.NewRecorder())
4144

4245
asset := models.Asset{}
46+
assetVersion := models.AssetVersion{}
47+
4348
core.SetAsset(ctx, asset)
49+
core.SetAssetVersion(ctx, assetVersion)
4450

4551
attestationRepository := mocks.NewCoreAttestationRepository(t)
46-
attestationRepository.On("GetByAssetID", mock.Anything).Return([]models.Attestation{}, fmt.Errorf("Something went wrong"))
52+
attestationRepository.On("GetByAssetVersionAndAssetID", mock.Anything, mock.Anything).Return([]models.Attestation{}, fmt.Errorf("Something went wrong"))
4753
attestationController := attestation.NewAttestationController(attestationRepository)
4854

4955
result := attestationController.List(ctx)

internal/core/common_interfaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ type AssetRepository interface {
5555
type AttestationRepository interface {
5656
common.Repository[string, models.Attestation, DB]
5757
GetByAssetID(assetID uuid.UUID) ([]models.Attestation, error)
58-
GetByAssetVersion(assetID uuid.UUID, assetVersion string) ([]models.Attestation, error)
58+
GetByAssetVersionAndAssetID(assetID uuid.UUID, assetVersion string) ([]models.Attestation, error)
5959
}
6060

6161
type CveRepository interface {

internal/database/repositories/attestation_repository.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (a *attestationRepository) GetByAssetID(assetID uuid.UUID) ([]models.Attest
3232
return attestationList, nil
3333
}
3434

35-
func (a *attestationRepository) GetByAssetVersion(assetID uuid.UUID, assetVersion string) ([]models.Attestation, error) {
35+
func (a *attestationRepository) GetByAssetVersionAndAssetID(assetID uuid.UUID, assetVersion string) ([]models.Attestation, error) {
3636
var attestationList []models.Attestation
3737
err := a.db.Where("asset_id = ? AND asset_version_name = ?", assetID, assetVersion).Find(&attestationList).Error
3838
if err != nil {

mocks/mock_core_AttestationRepository.go

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)