mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-07-04 19:52:30 +00:00
427 add more details to machine not found error message (#429)
* fix: add more details to machine not found error --------- Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
605b6c73d6
commit
e06fc55630
@ -20,7 +20,7 @@ func (k Keeper) GetMachineByAddress(goCtx context.Context, req *types.QueryGetMa
|
|||||||
|
|
||||||
machineIndex, found := k.GetMachineIndexByAddress(ctx, req.Address)
|
machineIndex, found := k.GetMachineIndexByAddress(ctx, req.Address)
|
||||||
if !found {
|
if !found {
|
||||||
return nil, status.Error(codes.NotFound, "machine not found")
|
return nil, status.Error(codes.NotFound, "machine not found by address: "+req.Address)
|
||||||
}
|
}
|
||||||
|
|
||||||
machine, found := k.GetMachine(ctx, machineIndex)
|
machine, found := k.GetMachine(ctx, machineIndex)
|
||||||
|
@ -29,7 +29,7 @@ func TestGetMachineByAddress(t *testing.T) {
|
|||||||
}, {
|
}, {
|
||||||
desc: "MachineNotFound",
|
desc: "MachineNotFound",
|
||||||
request: &types.QueryGetMachineByAddressRequest{Address: "invalid address"},
|
request: &types.QueryGetMachineByAddressRequest{Address: "invalid address"},
|
||||||
err: status.Error(codes.NotFound, "machine not found"),
|
err: status.Error(codes.NotFound, "machine not found by address: invalid address"),
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(tc.desc, func(t *testing.T) {
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
|
@ -20,7 +20,7 @@ func (k Keeper) GetMachineByPublicKey(goCtx context.Context, req *types.QueryGet
|
|||||||
|
|
||||||
machineIndex, found := k.GetMachineIndexByPubKey(ctx, req.PublicKey)
|
machineIndex, found := k.GetMachineIndexByPubKey(ctx, req.PublicKey)
|
||||||
if !found {
|
if !found {
|
||||||
return nil, status.Error(codes.NotFound, "machine not found")
|
return nil, status.Error(codes.NotFound, "machine not found by public key: "+req.PublicKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
machine, found := k.GetMachine(ctx, machineIndex)
|
machine, found := k.GetMachine(ctx, machineIndex)
|
||||||
|
@ -39,7 +39,7 @@ func TestGetMachineByPublicKey(t *testing.T) {
|
|||||||
}, {
|
}, {
|
||||||
desc: "MachineNotFound",
|
desc: "MachineNotFound",
|
||||||
request: &types.QueryGetMachineByPublicKeyRequest{PublicKey: "invalid key"},
|
request: &types.QueryGetMachineByPublicKeyRequest{PublicKey: "invalid key"},
|
||||||
err: status.Error(codes.NotFound, "machine not found"),
|
err: status.Error(codes.NotFound, "machine not found by public key: invalid key"),
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(tc.desc, func(t *testing.T) {
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
|
@ -20,7 +20,7 @@ func (k Keeper) GetTrustAnchorStatus(goCtx context.Context, req *types.QueryGetT
|
|||||||
|
|
||||||
_, activated, found := k.GetTrustAnchor(ctx, req.Machineid)
|
_, activated, found := k.GetTrustAnchor(ctx, req.Machineid)
|
||||||
if !found {
|
if !found {
|
||||||
return nil, status.Error(codes.NotFound, "trust anchor not found")
|
return nil, status.Error(codes.NotFound, "trust anchor not found by machine id: "+req.Machineid)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &types.QueryGetTrustAnchorStatusResponse{Machineid: req.Machineid, Isactivated: activated}, nil
|
return &types.QueryGetTrustAnchorStatusResponse{Machineid: req.Machineid, Isactivated: activated}, nil
|
||||||
|
@ -35,7 +35,7 @@ func TestGetTrustAnchorQuery(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "NotFound",
|
desc: "NotFound",
|
||||||
request: &types.QueryGetTrustAnchorStatusRequest{Machineid: "invalid MachineID"},
|
request: &types.QueryGetTrustAnchorStatusRequest{Machineid: "invalid MachineID"},
|
||||||
err: status.Error(codes.NotFound, "trust anchor not found"),
|
err: status.Error(codes.NotFound, "trust anchor not found by machine id: invalid MachineID"),
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(tc.desc, func(t *testing.T) {
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user