Use reflect.DeepEqual where possible. (#294)
Comparing each field manually is unnecessary and error-prone.
This commit is contained in:
parent
7f25f6614c
commit
67b4c6c019
@ -125,18 +125,7 @@ func testGetTicketByHash(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check ticket fields match expected.
|
// Check ticket fields match expected.
|
||||||
if retrieved.Hash != ticket.Hash ||
|
if !reflect.DeepEqual(retrieved, ticket) {
|
||||||
retrieved.CommitmentAddress != ticket.CommitmentAddress ||
|
|
||||||
retrieved.FeeAddressIndex != ticket.FeeAddressIndex ||
|
|
||||||
retrieved.FeeAddress != ticket.FeeAddress ||
|
|
||||||
retrieved.FeeAmount != ticket.FeeAmount ||
|
|
||||||
retrieved.FeeExpiration != ticket.FeeExpiration ||
|
|
||||||
retrieved.Confirmed != ticket.Confirmed ||
|
|
||||||
!reflect.DeepEqual(retrieved.VoteChoices, ticket.VoteChoices) ||
|
|
||||||
retrieved.VotingWIF != ticket.VotingWIF ||
|
|
||||||
retrieved.FeeTxHex != ticket.FeeTxHex ||
|
|
||||||
retrieved.FeeTxHash != ticket.FeeTxHash ||
|
|
||||||
retrieved.FeeTxStatus != ticket.FeeTxStatus {
|
|
||||||
t.Fatal("retrieved ticket value didnt match expected")
|
t.Fatal("retrieved ticket value didnt match expected")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,9 +166,7 @@ func testUpdateTicket(t *testing.T) {
|
|||||||
t.Fatal("expected found==true")
|
t.Fatal("expected found==true")
|
||||||
}
|
}
|
||||||
|
|
||||||
if ticket.FeeAmount != retrieved.FeeAmount ||
|
if !reflect.DeepEqual(retrieved, ticket) {
|
||||||
ticket.FeeExpiration != retrieved.FeeExpiration ||
|
|
||||||
!reflect.DeepEqual(retrieved.VoteChoices, ticket.VoteChoices) {
|
|
||||||
t.Fatal("retrieved ticket value didnt match expected")
|
t.Fatal("retrieved ticket value didnt match expected")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
package database
|
package database
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -33,11 +34,7 @@ func testVoteChangeRecords(t *testing.T) {
|
|||||||
t.Fatalf("error retrieving vote change records: %v", err)
|
t.Fatalf("error retrieving vote change records: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(retrieved) != 1 ||
|
if len(retrieved) != 1 || !reflect.DeepEqual(retrieved[0], record) {
|
||||||
retrieved[0].Request != record.Request ||
|
|
||||||
retrieved[0].RequestSignature != record.RequestSignature ||
|
|
||||||
retrieved[0].Response != record.Response ||
|
|
||||||
retrieved[0].ResponseSignature != record.ResponseSignature {
|
|
||||||
t.Fatal("retrieved record didnt match expected")
|
t.Fatal("retrieved record didnt match expected")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user