Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/graph/attestation.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion internal/graph/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions internal/graph/model/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion internal/repositories/attestation/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func New(indexService indexRepoService, chainID uint64, vehicleAddress common.Ad
}

// GetAttestations fetches attestations for the given vehicle.
func (r *Repository) GetAttestations(ctx context.Context, vehicleTokenID uint32, filter *model.AttestationFilter) ([]*model.Attestation, error) {
func (r *Repository) GetAttestations(ctx context.Context, vehicleTokenID int, filter *model.AttestationFilter) ([]*model.Attestation, error) {
vehicleDID := cloudevent.ERC721DID{
ChainID: r.chainID,
ContractAddress: r.vehicleAddress,
Expand Down Expand Up @@ -70,6 +70,10 @@ func (r *Repository) GetAttestations(ctx context.Context, vehicleTokenID uint32,
if filter.Limit != nil {
limit = *filter.Limit
}

if filter.ID != nil {
opts.Id = &wrapperspb.StringValue{Value: *filter.ID}
}
}

cloudEvents, err := r.indexService.GetAllCloudEvents(ctx, opts, int32(limit))
Expand Down
10 changes: 5 additions & 5 deletions internal/repositories/attestation/attestation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (m *MockRow) ScanStruct(any) error {
return nil
}

func TestAttestation(t *testing.T) {
func TestGetAttestations(t *testing.T) {
// Initialize variables
ctx := context.Background()
validVehTknID := int(123)
Expand Down Expand Up @@ -88,7 +88,7 @@ func TestAttestation(t *testing.T) {
tests := []struct {
name string
mockSetup func()
vehTknID uint32
vehTknID int
filters *model.AttestationFilter
expectedAtts []*model.Attestation
expectedErr bool
Expand All @@ -101,7 +101,7 @@ func TestAttestation(t *testing.T) {
defaultEvent,
}, nil)
},
vehTknID: uint32(validVehTknID),
vehTknID: validVehTknID,
expectedAtts: []*model.Attestation{
&model.Attestation{
ID: id,
Expand Down Expand Up @@ -130,7 +130,7 @@ func TestAttestation(t *testing.T) {
Source: &validSigner,
Limit: &limit,
},
vehTknID: uint32(validVehTknID),
vehTknID: validVehTknID,
expectedAtts: []*model.Attestation{
&model.Attestation{
ID: id,
Expand All @@ -149,7 +149,7 @@ func TestAttestation(t *testing.T) {
mockSetup: func() {
mockService.EXPECT().GetAllCloudEvents(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil)
},
vehTknID: uint32(invalidVehTknID),
vehTknID: invalidVehTknID,
},
}

Expand Down
5 changes: 5 additions & 0 deletions schema/attestation.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ type Attestation {
AttestationFilter holds the filter parameters for the attestation querys.
"""
input AttestationFilter {
"""
id is the id of the attestation.
"""
id: String

"""
The attesting party.
"""
Expand Down