storagenode: Add more test assertions (#2772)
This commit is contained in:
parent
9eba5ac631
commit
26fb992474
@ -149,13 +149,17 @@ func TestDB_Trivial(t *testing.T) {
|
||||
}
|
||||
|
||||
{ // Ensure ListUnsent works at all
|
||||
_, err := db.Orders().ListUnsent(ctx, 1)
|
||||
infos, err := db.Orders().ListUnsent(ctx, 1)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, infos, 1)
|
||||
}
|
||||
|
||||
{ // Ensure ListUnsentBySatellite works at all
|
||||
_, err := db.Orders().ListUnsentBySatellite(ctx)
|
||||
infos, err := db.Orders().ListUnsentBySatellite(ctx)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, infos, 1)
|
||||
require.Contains(t, infos, satelliteID)
|
||||
require.Len(t, infos[satelliteID], 1)
|
||||
}
|
||||
|
||||
{ // Ensure Archive works at all
|
||||
@ -164,8 +168,9 @@ func TestDB_Trivial(t *testing.T) {
|
||||
}
|
||||
|
||||
{ // Ensure ListArchived works at all
|
||||
_, err := db.Orders().ListArchived(ctx, 1)
|
||||
infos, err := db.Orders().ListArchived(ctx, 1)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, infos, 1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -140,7 +140,6 @@ func TestUpload(t *testing.T) {
|
||||
},
|
||||
} {
|
||||
data := testrand.Bytes(tt.contentLength)
|
||||
expectedHash := pkcrypto.SHA256Hash(data)
|
||||
serialNumber := testrand.SerialNumber()
|
||||
|
||||
orderLimit, piecePrivateKey := GenerateOrderLimit(
|
||||
@ -171,6 +170,7 @@ func TestUpload(t *testing.T) {
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedHash := pkcrypto.SHA256Hash(data)
|
||||
assert.Equal(t, expectedHash, pieceHash.Hash)
|
||||
|
||||
signee := signing.SignerFromFullIdentity(planet.StorageNodes[0].Identity)
|
||||
@ -230,6 +230,11 @@ func TestDownload(t *testing.T) {
|
||||
pieceID: orderLimit.PieceId,
|
||||
action: pb.PieceAction_GET,
|
||||
},
|
||||
{ // should err with piece ID not specified
|
||||
pieceID: storj.PieceID{},
|
||||
action: pb.PieceAction_GET,
|
||||
errs: []string{"missing piece id"},
|
||||
},
|
||||
{ // should err with piece ID not specified
|
||||
pieceID: storj.PieceID{2},
|
||||
action: pb.PieceAction_GET,
|
||||
@ -327,17 +332,22 @@ func TestDelete(t *testing.T) {
|
||||
action pb.PieceAction
|
||||
err string
|
||||
}{
|
||||
{ // should successfully download data
|
||||
{ // should successfully delete data
|
||||
pieceID: orderLimit.PieceId,
|
||||
action: pb.PieceAction_DELETE,
|
||||
err: "",
|
||||
},
|
||||
{ // should err with piece ID not specified
|
||||
{ // should err with piece ID not found
|
||||
pieceID: storj.PieceID{99},
|
||||
action: pb.PieceAction_DELETE,
|
||||
err: "", // TODO should this return error
|
||||
},
|
||||
{ // should successfully download data
|
||||
{ // should err with piece ID not specified
|
||||
pieceID: storj.PieceID{},
|
||||
action: pb.PieceAction_DELETE,
|
||||
err: "missing piece id",
|
||||
},
|
||||
{ // should err due to incorrect action
|
||||
pieceID: orderLimit.PieceId,
|
||||
action: pb.PieceAction_GET,
|
||||
err: "expected delete action got GET",
|
||||
|
Loading…
Reference in New Issue
Block a user