-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[MB-5354][MB-5536] Fix bug in fetch-mto-updates causing identical destination addresses #5267
Changes from all commits
b58e5ea
61cd101
b6136a2
f18cd60
ac37ddf
f9b2631
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,8 +53,8 @@ func MoveTaskOrders(moveTaskOrders *models.Moves) []*primemessages.MoveTaskOrder | |
payload := make(primemessages.MoveTaskOrders, len(*moveTaskOrders)) | ||
|
||
for i, m := range *moveTaskOrders { | ||
// #nosec G601 TODO needs review | ||
payload[i] = MoveTaskOrder(&m) | ||
copyOfM := m // Make copy to avoid implicit memory aliasing of items from a range statement. | ||
payload[i] = MoveTaskOrder(©OfM) | ||
Comment on lines
+56
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other way to do is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, although that changes the signatures all the way down this chain which would have a ripple effect on any callers since these are public methods (I haven't dug in to see how painful it would be, so it may not end up being that bad). But I will add something to the Wiki page noting this as another option. |
||
} | ||
return payload | ||
} | ||
|
@@ -215,8 +215,8 @@ func MTOAgents(mtoAgents *models.MTOAgents) *primemessages.MTOAgents { | |
agents := make(primemessages.MTOAgents, len(*mtoAgents)) | ||
|
||
for i, m := range *mtoAgents { | ||
// #nosec G601 TODO needs review | ||
agents[i] = MTOAgent(&m) | ||
copyOfM := m // Make copy to avoid implicit memory aliasing of items from a range statement. | ||
agents[i] = MTOAgent(©OfM) | ||
} | ||
|
||
return &agents | ||
|
@@ -250,8 +250,8 @@ func PaymentRequests(paymentRequests *models.PaymentRequests) *primemessages.Pay | |
payload := make(primemessages.PaymentRequests, len(*paymentRequests)) | ||
|
||
for i, p := range *paymentRequests { | ||
// #nosec G601 TODO needs review | ||
payload[i] = PaymentRequest(&p) | ||
copyOfP := p // Make copy to avoid implicit memory aliasing of items from a range statement. | ||
payload[i] = PaymentRequest(©OfP) | ||
} | ||
return &payload | ||
} | ||
|
@@ -291,8 +291,8 @@ func PaymentServiceItems(paymentServiceItems *models.PaymentServiceItems) *prime | |
payload := make(primemessages.PaymentServiceItems, len(*paymentServiceItems)) | ||
|
||
for i, p := range *paymentServiceItems { | ||
// #nosec G601 TODO needs review | ||
payload[i] = PaymentServiceItem(&p) | ||
copyOfP := p // Make copy to avoid implicit memory aliasing of items from a range statement. | ||
payload[i] = PaymentServiceItem(©OfP) | ||
} | ||
return &payload | ||
} | ||
|
@@ -323,8 +323,8 @@ func PaymentServiceItemParams(paymentServiceItemParams *models.PaymentServiceIte | |
payload := make(primemessages.PaymentServiceItemParams, len(*paymentServiceItemParams)) | ||
|
||
for i, p := range *paymentServiceItemParams { | ||
// #nosec G601 TODO needs review | ||
payload[i] = PaymentServiceItemParam(&p) | ||
copyOfP := p // Make copy to avoid implicit memory aliasing of items from a range statement. | ||
payload[i] = PaymentServiceItemParam(©OfP) | ||
} | ||
return &payload | ||
} | ||
|
@@ -393,8 +393,8 @@ func MTOShipments(mtoShipments *models.MTOShipments) *primemessages.MTOShipments | |
payload := make(primemessages.MTOShipments, len(*mtoShipments)) | ||
|
||
for i, m := range *mtoShipments { | ||
// #nosec G601 TODO needs review | ||
payload[i] = MTOShipment(&m) | ||
copyOfM := m // Make copy to avoid implicit memory aliasing of items from a range statement. | ||
payload[i] = MTOShipment(©OfM) | ||
} | ||
return &payload | ||
} | ||
|
@@ -475,8 +475,8 @@ func MTOServiceItems(mtoServiceItems *models.MTOServiceItems) *[]primemessages.M | |
var payload []primemessages.MTOServiceItem | ||
|
||
for _, p := range *mtoServiceItems { | ||
// #nosec G601 TODO needs review | ||
payload = append(payload, MTOServiceItem(&p)) | ||
copyOfP := p // Make copy to avoid implicit memory aliasing of items from a range statement. | ||
payload = append(payload, MTOServiceItem(©OfP)) | ||
} | ||
return &payload | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1617,6 +1617,43 @@ func createMoveWithBasicServiceItems(db *pop.Connection, userUploader *uploader. | |
) | ||
} | ||
|
||
func createMoveWithUniqueDestinationAddress(db *pop.Connection) { | ||
address := testdatagen.MakeAddress(db, testdatagen.Assertions{ | ||
Address: models.Address{ | ||
StreetAddress1: "2 Second St", | ||
StreetAddress2: swag.String("Apt 2"), | ||
StreetAddress3: swag.String("Suite B"), | ||
City: "Columbia", | ||
State: "SC", | ||
PostalCode: "29212", | ||
Country: swag.String("US"), | ||
}, | ||
}) | ||
|
||
newDutyStation := testdatagen.MakeDutyStation(db, testdatagen.Assertions{ | ||
DutyStation: models.DutyStation{ | ||
AddressID: address.ID, | ||
Address: address, | ||
}, | ||
}) | ||
|
||
moveOrder := testdatagen.MakeOrder(db, testdatagen.Assertions{ | ||
Order: models.Order{ | ||
NewDutyStationID: newDutyStation.ID, | ||
NewDutyStation: newDutyStation, | ||
}, | ||
}) | ||
|
||
testdatagen.MakeMove(db, testdatagen.Assertions{ | ||
Move: models.Move{ | ||
ID: uuid.FromStringOrNil("ecbc2e6a-1b45-403b-9bd4-ea315d4d3d93"), | ||
AvailableToPrimeAt: swag.Time(time.Now()), | ||
Status: models.MoveStatusAPPROVED, | ||
}, | ||
Order: moveOrder, | ||
}) | ||
} | ||
|
||
// Run does that data load thing | ||
func (e devSeedScenario) Run(db *pop.Connection, userUploader *uploader.UserUploader, primeUploader *uploader.PrimeUploader, logger Logger, storer *storage.Filesystem) { | ||
// PPM Office Queue | ||
|
@@ -1655,4 +1692,7 @@ func (e devSeedScenario) Run(db *pop.Connection, userUploader *uploader.UserUplo | |
// This move below is a PPM move in DRAFT status. It should probably | ||
// be changed to an HHG move in SUBMITTED status to reflect reality. | ||
createMoveWithBasicServiceItems(db, userUploader) | ||
// Sets up a move with a non-default destination duty station address | ||
// (to more easily spot issues with addresses being overwritten). | ||
createMoveWithUniqueDestinationAddress(db) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a blocker for this PR, but I've noted other places where we use the same data, such as the same email for service members, where it would be better to have unique data using some kind of faker package. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. I think we miss some bugs like this because of the similar nature of the default objects we're creating. |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent use of helper functions!