From afc4b5b77f9200d914323567d0c291aecab46ab0 Mon Sep 17 00:00:00 2001 From: KonstanceH Date: Mon, 1 Jul 2024 16:29:02 +0000 Subject: [PATCH 01/12] removed query line that adds closeout complete --- pkg/services/order/order_fetcher.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/services/order/order_fetcher.go b/pkg/services/order/order_fetcher.go index 0547c9f1e49..7cd76f07867 100644 --- a/pkg/services/order/order_fetcher.go +++ b/pkg/services/order/order_fetcher.go @@ -175,7 +175,7 @@ func (f orderFetcher) ListOrders(appCtx appcontext.AppContext, officeUserID uuid if *params.NeedsPPMCloseout { query.InnerJoin("ppm_shipments", "ppm_shipments.shipment_id = mto_shipments.id"). LeftJoin("transportation_offices as closeout_to", "closeout_to.id = moves.closeout_office_id"). - Where("ppm_shipments.status IN (?)", models.PPMShipmentStatusWaitingOnCustomer, models.PPMShipmentStatusNeedsCloseout, models.PPMShipmentStatusCloseoutComplete). + Where("ppm_shipments.status IN (?)", models.PPMShipmentStatusWaitingOnCustomer, models.PPMShipmentStatusNeedsCloseout). Where("service_members.affiliation NOT IN (?)", models.AffiliationNAVY, models.AffiliationMARINES, models.AffiliationCOASTGUARD) } else { query.LeftJoin("ppm_shipments", "ppm_shipments.shipment_id = mto_shipments.id"). From 65f0b0da4671362ae5d9f1fc92040bd85910c19e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 11:13:02 +0000 Subject: [PATCH 02/12] Bump github.com/gorilla/csrf from 1.7.1 to 1.7.2 Bumps [github.com/gorilla/csrf](https://github.com/gorilla/csrf) from 1.7.1 to 1.7.2. - [Release notes](https://github.com/gorilla/csrf/releases) - [Commits](https://github.com/gorilla/csrf/compare/v1.7.1...v1.7.2) --- updated-dependencies: - dependency-name: github.com/gorilla/csrf dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 093a162a3ae..e1bf0d6a7ef 100644 --- a/go.mod +++ b/go.mod @@ -48,7 +48,7 @@ require ( github.com/golang-jwt/jwt/v4 v4.5.0 github.com/gomodule/redigo v1.9.2 github.com/google/go-github/v31 v31.0.0 - github.com/gorilla/csrf v1.7.1 + github.com/gorilla/csrf v1.7.2 github.com/imdario/mergo v0.3.16 github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa github.com/jessevdk/go-flags v1.5.0 @@ -186,7 +186,7 @@ require ( github.com/gookit/color v1.5.4 // indirect github.com/gorilla/css v1.0.0 // indirect github.com/gorilla/handlers v1.5.1 // indirect - github.com/gorilla/securecookie v1.1.1 // indirect + github.com/gorilla/securecookie v1.1.2 // indirect github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect diff --git a/go.sum b/go.sum index 141fa917263..d83726c9823 100644 --- a/go.sum +++ b/go.sum @@ -282,6 +282,8 @@ github.com/google/go-github/v31 v31.0.0 h1:JJUxlP9lFK+ziXKimTCprajMApV1ecWD4NB6C github.com/google/go-github/v31 v31.0.0/go.mod h1:NQPZol8/1sMoWYGN2yaALIBytu17gAWfhbweiEed3pM= github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= @@ -293,14 +295,14 @@ github.com/gookit/color v1.4.2/go.mod h1:fqRyamkC1W8uxl+lxCQxOT09l/vYfZ+QeiX3rKQ github.com/gookit/color v1.5.0/go.mod h1:43aQb+Zerm/BWh2GnrgOQm7ffz7tvQXEKV6BFMl7wAo= github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0= github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w= -github.com/gorilla/csrf v1.7.1 h1:Ir3o2c1/Uzj6FBxMlAUB6SivgVMy1ONXwYgXn+/aHPE= -github.com/gorilla/csrf v1.7.1/go.mod h1:+a/4tCmqhG6/w4oafeAZ9pEa3/NZOWYVbD9fV0FwIQA= +github.com/gorilla/csrf v1.7.2 h1:oTUjx0vyf2T+wkrx09Trsev1TE+/EbDAeHtSTbtC2eI= +github.com/gorilla/csrf v1.7.2/go.mod h1:F1Fj3KG23WYHE6gozCmBAezKookxbIvUJT+121wTuLk= github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY= github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c= github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= -github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= -github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= +github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA= +github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= From ae5f1fdd18609c4bee19478dc10a437588dd36d3 Mon Sep 17 00:00:00 2001 From: KonstanceH Date: Mon, 8 Jul 2024 19:33:00 +0000 Subject: [PATCH 03/12] adding in tests --- pkg/services/order/order_fetcher_test.go | 492 +++++++---------------- 1 file changed, 140 insertions(+), 352 deletions(-) diff --git a/pkg/services/order/order_fetcher_test.go b/pkg/services/order/order_fetcher_test.go index 83f3a68b44c..480087bcf34 100644 --- a/pkg/services/order/order_fetcher_test.go +++ b/pkg/services/order/order_fetcher_test.go @@ -633,9 +633,88 @@ func (suite *OrderServiceSuite) TestListOrdersUSMCGBLOC() { }) } +func getMoveNeedsServiceCounseling(suite *OrderServiceSuite, showMove bool, affiliation models.ServiceMemberAffiliation) models.Move { + nonCloseoutMove := factory.BuildMove(suite.DB(), []factory.Customization{ + { + Model: models.Move{ + Status: models.MoveStatusNeedsServiceCounseling, + Show: &showMove, + }, + }, + { + Model: models.ServiceMember{ + Affiliation: &affiliation, + }, + }, + }, nil) + + return nonCloseoutMove +} + +func getSubmittedMove(suite *OrderServiceSuite, showMove bool, affiliation models.ServiceMemberAffiliation) models.Move { + move := factory.BuildMove(suite.DB(), []factory.Customization{ + { + Model: models.Move{ + Status: models.MoveStatusSUBMITTED, + Show: &showMove, + }, + }, + { + Model: models.ServiceMember{ + Affiliation: &affiliation, + }, + }, + }, nil) + return move +} + +func buildPPMShipmentNeedsCloseout(suite *OrderServiceSuite, move models.Move) models.PPMShipment { + ppm := factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ + { + Model: models.PPMShipment{ + Status: models.PPMShipmentStatusNeedsCloseout, + }, + }, + { + Model: move, + LinkOnly: true, + }, + }, nil) + return ppm +} + +func buildPPMShipmentDraft(suite *OrderServiceSuite, move models.Move) models.PPMShipment { + ppm := factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ + { + Model: models.PPMShipment{ + Status: models.PPMShipmentStatusDraft, + }, + }, + { + Model: move, + LinkOnly: true, + }, + }, nil) + return ppm +} + +func buildPPMShipmentCloseoutComplete(suite *OrderServiceSuite, move models.Move) models.PPMShipment { + ppm := factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ + { + Model: models.PPMShipment{ + Status: models.PPMShipmentStatusCloseoutComplete, + }, + }, + { + Model: move, + LinkOnly: true, + }, + }, nil) + return ppm +} + func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForArmyAirforce() { orderFetcher := NewOrderFetcher() - showMove := true var session auth.Session @@ -649,85 +728,15 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForArmyAirforce() { IDToken: "fake_token", AccessToken: "fakeAccessToken", } + + move := getMoveNeedsServiceCounseling(suite, true, models.AffiliationARMY) + buildPPMShipmentNeedsCloseout(suite, move) - army := models.AffiliationARMY - move := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusNeedsServiceCounseling, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &army, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusNeedsCloseout, - }, - }, - { - Model: move, - LinkOnly: true, - }, - }, nil) - // Moves that are not ready for closeout should not show in this queue - af := models.AffiliationAIRFORCE - afMove := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusNeedsServiceCounseling, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &af, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusDraft, - }, - }, - { - Model: afMove, - LinkOnly: true, - }, - }, nil) - // Coast guard moves should not show up in our office user's closeout queue - cg := models.AffiliationCOASTGUARD - cgMove := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusNeedsServiceCounseling, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &cg, - }, - }, - }, nil) + afMove := getMoveNeedsServiceCounseling(suite, true, models.AffiliationAIRFORCE) + buildPPMShipmentDraft(suite, afMove) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusNeedsCloseout, - }, - }, - { - Model: cgMove, - LinkOnly: true, - }, - }, nil) + cgMove := getMoveNeedsServiceCounseling(suite, true, models.AffiliationCOASTGUARD) + buildPPMShipmentNeedsCloseout(suite, cgMove) params := services.ListOrderParams{PerPage: models.Int64Pointer(9), Page: models.Int64Pointer(1), NeedsPPMCloseout: models.BoolPointer(true), Status: []string{string(models.MoveStatusNeedsServiceCounseling)}} moves, _, err := orderFetcher.ListOrders(suite.AppContextWithSessionForTest(&session), officeUserSC.ID, ¶ms) @@ -748,58 +757,12 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForArmyAirforce() { AccessToken: "fakeAccessToken", } - // PPM moves that need closeout should not show up in counseling queue - army := models.AffiliationARMY - closeoutMove := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusNeedsServiceCounseling, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &army, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusNeedsCloseout, - }, - }, - { - Model: closeoutMove, - LinkOnly: true, - }, - }, nil) + closeoutMove := getMoveNeedsServiceCounseling(suite, true, models.AffiliationARMY) + buildPPMShipmentCloseoutComplete(suite, closeoutMove) + // PPM moves that are not in one of the closeout statuses - airforce := models.AffiliationAIRFORCE - nonCloseoutMove := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusNeedsServiceCounseling, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &airforce, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusDraft, - }, - }, - { - Model: nonCloseoutMove, - LinkOnly: true, - }, - }, nil) + nonCloseoutMove := getMoveNeedsServiceCounseling(suite, true, models.AffiliationAIRFORCE) + buildPPMShipmentDraft(suite, nonCloseoutMove) params := services.ListOrderParams{PerPage: models.Int64Pointer(9), Page: models.Int64Pointer(1), NeedsPPMCloseout: models.BoolPointer(false), Status: []string{string(models.MoveStatusNeedsServiceCounseling)}} moves, _, err := orderFetcher.ListOrders(suite.AppContextWithSessionForTest(&session), officeUserSC.ID, ¶ms) @@ -812,62 +775,17 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForArmyAirforce() { func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForNavyCoastGuardAndMarines() { orderFetcher := NewOrderFetcher() - showMove := true suite.Run("returns Navy order for NAVY office user when there's a ppm shipment in closeout", func() { - navy := models.AffiliationNAVY // It doesn't matter what the Origin GBLOC is for the move. Only the navy // affiliation matters for SC who are tied to the NAVY GBLOC. - move := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusSUBMITTED, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &navy, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusNeedsCloseout, - }, - }, - { - Model: move, - LinkOnly: true, - }, - }, nil) - cg := models.AffiliationCOASTGUARD - cgMove := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusSUBMITTED, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &cg, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusNeedsCloseout, - }, - }, - { - Model: cgMove, - LinkOnly: true, - }, - }, nil) + move := getSubmittedMove(suite, true, models.AffiliationNAVY) + buildPPMShipmentNeedsCloseout(suite, move) + + cgMove := getSubmittedMove(suite, true, models.AffiliationCOASTGUARD) + buildPPMShipmentNeedsCloseout(suite, cgMove) + officeUserSC := factory.BuildOfficeUserWithRoles(suite.DB(), []factory.Customization{ { Model: models.TransportationOffice{ @@ -894,58 +812,14 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForNavyCoastGuardAndMar }) suite.Run("returns TVCB order for TVCB office user when there's a ppm shipment in closeout", func() { - marines := models.AffiliationMARINES // It doesn't matter what the Origin GBLOC is for the move. Only the marines // affiliation matters for SC who are tied to the TVCB GBLOC. - move := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusSUBMITTED, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &marines, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusNeedsCloseout, - }, - }, - { - Model: move, - LinkOnly: true, - }, - }, nil) - army := models.AffiliationARMY - nonMarineMove := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusSUBMITTED, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &army, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusNeedsCloseout, - }, - }, - { - Model: nonMarineMove, - LinkOnly: true, - }, - }, nil) + move := getSubmittedMove(suite, true, models.AffiliationMARINES) + buildPPMShipmentNeedsCloseout(suite, move) + + nonMarineMove := getSubmittedMove(suite, true, models.AffiliationARMY) + buildPPMShipmentNeedsCloseout(suite, nonMarineMove) + officeUserSC := factory.BuildOfficeUserWithRoles(suite.DB(), []factory.Customization{ { Model: models.TransportationOffice{ @@ -972,58 +846,14 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForNavyCoastGuardAndMar }) suite.Run("returns coast guard order for USCG office user when there's a ppm shipment in closeout and filters out non coast guard moves", func() { - cg := models.AffiliationCOASTGUARD // It doesn't matter what the Origin GBLOC is for the move. Only the coast guard // affiliation matters for SC who are tied to the USCG GBLOC. - move := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusSUBMITTED, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &cg, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusNeedsCloseout, - }, - }, - { - Model: move, - LinkOnly: true, - }, - }, nil) - army := models.AffiliationARMY - armyMove := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusSUBMITTED, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &army, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusNeedsCloseout, - }, - }, - { - Model: armyMove, - LinkOnly: true, - }, - }, nil) + move := getSubmittedMove(suite, true, models.AffiliationCOASTGUARD) + buildPPMShipmentNeedsCloseout(suite, move) + + armyMove := getSubmittedMove(suite, true, models.AffiliationARMY) + buildPPMShipmentNeedsCloseout(suite, armyMove) + officeUserSC := factory.BuildOfficeUserWithRoles(suite.DB(), []factory.Customization{ { Model: models.TransportationOffice{ @@ -1049,32 +879,9 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForNavyCoastGuardAndMar }) suite.Run("Filters out moves with PPM shipments not in the status of NeedsApproval", func() { - cg := models.AffiliationCOASTGUARD + cgMoveInWrongStatus := getSubmittedMove(suite, true, models.AffiliationCOASTGUARD) + buildPPMShipmentCloseoutComplete(suite, cgMoveInWrongStatus) - cgMoveInWrongStatus := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusSUBMITTED, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &cg, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusCloseoutComplete, - }, - }, - { - Model: cgMoveInWrongStatus, - LinkOnly: true, - }, - }, nil) officeUserSC := factory.BuildOfficeUserWithRoles(suite.DB(), []factory.Customization{ { Model: models.TransportationOffice{ @@ -1091,21 +898,8 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForNavyCoastGuardAndMar }) suite.Run("Filters out moves with no PPM shipment", func() { - cg := models.AffiliationCOASTGUARD + moveWithHHG := getSubmittedMove(suite, true, models.AffiliationCOASTGUARD) - moveWithHHG := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusSUBMITTED, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &cg, - }, - }, - }, nil) factory.BuildMTOShipment(suite.DB(), []factory.Customization{ { Model: models.MTOShipment{ @@ -1465,6 +1259,27 @@ func (suite *OrderServiceSuite) TestListOrdersWithSortOrder() { }) } +func getTransportationOffice(suite *OrderServiceSuite, name string) models.TransportationOffice { + trasportationOffice := factory.BuildTransportationOffice(suite.DB(), []factory.Customization{ + { + Model: models.TransportationOffice{ + Name: name, + }, + }}, nil) + return trasportationOffice +} + +func getPPMShipmentWithCloseoutOfficeNeedsCloseout(suite *OrderServiceSuite, closeoutOffice models.TransportationOffice) models.PPMShipment { + ppm := factory.BuildPPMShipmentThatNeedsCloseout(suite.DB(), nil, []factory.Customization{ + { + Model: closeoutOffice, + LinkOnly: true, + Type: &factory.TransportationOffices.CloseoutOffice, + }, + }) + return ppm +} + func (suite *OrderServiceSuite) TestListOrdersNeedingServicesCounselingWithPPMCloseoutColumnsSort() { defaultShipmentPickupPostalCode := "90210" setupTestData := func() models.OfficeUser { @@ -1549,32 +1364,11 @@ func (suite *OrderServiceSuite) TestListOrdersNeedingServicesCounselingWithPPMCl suite.Run("Sort by PPM closeout location", func() { officeUser := setupTestData() - locationA := factory.BuildTransportationOffice(suite.DB(), []factory.Customization{ - { - Model: models.TransportationOffice{ - Name: "A", - }, - }}, nil) - ppmShipmentA := factory.BuildPPMShipmentThatNeedsCloseout(suite.DB(), nil, []factory.Customization{ - { - Model: locationA, - LinkOnly: true, - Type: &factory.TransportationOffices.CloseoutOffice, - }, - }) - locationB := factory.BuildTransportationOffice(suite.DB(), []factory.Customization{ - { - Model: models.TransportationOffice{ - Name: "B", - }, - }}, nil) - ppmShipmentB := factory.BuildPPMShipmentThatNeedsCloseout(suite.DB(), nil, []factory.Customization{ - { - Model: locationB, - LinkOnly: true, - Type: &factory.TransportationOffices.CloseoutOffice, - }, - }) + locationA := getTransportationOffice(suite, "A") + ppmShipmentA := getPPMShipmentWithCloseoutOfficeNeedsCloseout(suite, locationA) + + locationB := getTransportationOffice(suite, "B") + ppmShipmentB := getPPMShipmentWithCloseoutOfficeNeedsCloseout(suite, locationB) // Sort by closeout location (ascending) moves, _, err := orderFetcher.ListOrders(suite.AppContextWithSessionForTest(&session), officeUser.ID, &services.ListOrderParams{ @@ -1737,13 +1531,7 @@ func (suite *OrderServiceSuite) TestListOrdersNeedingServicesCounselingWithPPMCl Model: models.TransportationOffice{Gbloc: "KKFA"}, }, }, nil) - ppmShipmentNeedsCloseout := factory.BuildPPMShipmentThatNeedsCloseout(suite.DB(), nil, []factory.Customization{ - { - Model: closeoutOffice, - LinkOnly: true, - Type: &factory.TransportationOffices.CloseoutOffice, - }, - }) + ppmShipmentNeedsCloseout := getPPMShipmentWithCloseoutOfficeNeedsCloseout(suite, closeoutOffice) ppmShipmentWaitingOnCustomer := factory.BuildPPMShipmentWaitingOnCustomer(suite.DB(), nil, []factory.Customization{ { Model: closeoutOffice, From 2f34db3d127a54373285d83af8f011975987a4e4 Mon Sep 17 00:00:00 2001 From: KonstanceH Date: Mon, 8 Jul 2024 20:04:55 +0000 Subject: [PATCH 04/12] linter change --- pkg/services/order/order_fetcher_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/services/order/order_fetcher_test.go b/pkg/services/order/order_fetcher_test.go index 480087bcf34..00ca4bc79e0 100644 --- a/pkg/services/order/order_fetcher_test.go +++ b/pkg/services/order/order_fetcher_test.go @@ -728,7 +728,7 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForArmyAirforce() { IDToken: "fake_token", AccessToken: "fakeAccessToken", } - + move := getMoveNeedsServiceCounseling(suite, true, models.AffiliationARMY) buildPPMShipmentNeedsCloseout(suite, move) From d5b0644181ea7a7473c3872a74ce33ba1715ecb3 Mon Sep 17 00:00:00 2001 From: KonstanceH Date: Mon, 8 Jul 2024 20:21:49 +0000 Subject: [PATCH 05/12] adding missing spaces --- pkg/services/order/order_fetcher_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/services/order/order_fetcher_test.go b/pkg/services/order/order_fetcher_test.go index 00ca4bc79e0..0454f0d5701 100644 --- a/pkg/services/order/order_fetcher_test.go +++ b/pkg/services/order/order_fetcher_test.go @@ -879,6 +879,7 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForNavyCoastGuardAndMar }) suite.Run("Filters out moves with PPM shipments not in the status of NeedsApproval", func() { + cgMoveInWrongStatus := getSubmittedMove(suite, true, models.AffiliationCOASTGUARD) buildPPMShipmentCloseoutComplete(suite, cgMoveInWrongStatus) @@ -898,8 +899,8 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForNavyCoastGuardAndMar }) suite.Run("Filters out moves with no PPM shipment", func() { + moveWithHHG := getSubmittedMove(suite, true, models.AffiliationCOASTGUARD) - factory.BuildMTOShipment(suite.DB(), []factory.Customization{ { Model: models.MTOShipment{ From 951efb923b9f92c381ea78ee5fbecbeebba4c930 Mon Sep 17 00:00:00 2001 From: KonstanceH Date: Mon, 8 Jul 2024 20:27:47 +0000 Subject: [PATCH 06/12] remove extra space --- pkg/services/order/order_fetcher_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/services/order/order_fetcher_test.go b/pkg/services/order/order_fetcher_test.go index 0454f0d5701..3ef8fc0f87b 100644 --- a/pkg/services/order/order_fetcher_test.go +++ b/pkg/services/order/order_fetcher_test.go @@ -712,7 +712,6 @@ func buildPPMShipmentCloseoutComplete(suite *OrderServiceSuite, move models.Move }, nil) return ppm } - func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForArmyAirforce() { orderFetcher := NewOrderFetcher() From c907b7dc9b0bd88a9ad3b9eb0016f15676d64d3b Mon Sep 17 00:00:00 2001 From: KonstanceH Date: Mon, 8 Jul 2024 20:30:51 +0000 Subject: [PATCH 07/12] fixing line spacing --- pkg/services/order/order_fetcher_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/services/order/order_fetcher_test.go b/pkg/services/order/order_fetcher_test.go index 3ef8fc0f87b..f0ee5cae801 100644 --- a/pkg/services/order/order_fetcher_test.go +++ b/pkg/services/order/order_fetcher_test.go @@ -762,6 +762,7 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForArmyAirforce() { // PPM moves that are not in one of the closeout statuses nonCloseoutMove := getMoveNeedsServiceCounseling(suite, true, models.AffiliationAIRFORCE) buildPPMShipmentDraft(suite, nonCloseoutMove) + params := services.ListOrderParams{PerPage: models.Int64Pointer(9), Page: models.Int64Pointer(1), NeedsPPMCloseout: models.BoolPointer(false), Status: []string{string(models.MoveStatusNeedsServiceCounseling)}} moves, _, err := orderFetcher.ListOrders(suite.AppContextWithSessionForTest(&session), officeUserSC.ID, ¶ms) From 0210cf64eff9bb451abb3b184d32dd8dfea24e86 Mon Sep 17 00:00:00 2001 From: KonstanceH Date: Mon, 8 Jul 2024 20:33:26 +0000 Subject: [PATCH 08/12] contd --- pkg/services/order/order_fetcher_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/services/order/order_fetcher_test.go b/pkg/services/order/order_fetcher_test.go index f0ee5cae801..b9a9fab6748 100644 --- a/pkg/services/order/order_fetcher_test.go +++ b/pkg/services/order/order_fetcher_test.go @@ -762,7 +762,7 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForArmyAirforce() { // PPM moves that are not in one of the closeout statuses nonCloseoutMove := getMoveNeedsServiceCounseling(suite, true, models.AffiliationAIRFORCE) buildPPMShipmentDraft(suite, nonCloseoutMove) - + params := services.ListOrderParams{PerPage: models.Int64Pointer(9), Page: models.Int64Pointer(1), NeedsPPMCloseout: models.BoolPointer(false), Status: []string{string(models.MoveStatusNeedsServiceCounseling)}} moves, _, err := orderFetcher.ListOrders(suite.AppContextWithSessionForTest(&session), officeUserSC.ID, ¶ms) @@ -779,7 +779,6 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForNavyCoastGuardAndMar suite.Run("returns Navy order for NAVY office user when there's a ppm shipment in closeout", func() { // It doesn't matter what the Origin GBLOC is for the move. Only the navy // affiliation matters for SC who are tied to the NAVY GBLOC. - move := getSubmittedMove(suite, true, models.AffiliationNAVY) buildPPMShipmentNeedsCloseout(suite, move) From 3e8208d5c65e2d51d935612c4f1f8486135bc125 Mon Sep 17 00:00:00 2001 From: KonstanceH Date: Mon, 8 Jul 2024 20:37:49 +0000 Subject: [PATCH 09/12] .. --- pkg/services/order/order_fetcher_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/services/order/order_fetcher_test.go b/pkg/services/order/order_fetcher_test.go index b9a9fab6748..b6f8dfda7bf 100644 --- a/pkg/services/order/order_fetcher_test.go +++ b/pkg/services/order/order_fetcher_test.go @@ -878,7 +878,6 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForNavyCoastGuardAndMar }) suite.Run("Filters out moves with PPM shipments not in the status of NeedsApproval", func() { - cgMoveInWrongStatus := getSubmittedMove(suite, true, models.AffiliationCOASTGUARD) buildPPMShipmentCloseoutComplete(suite, cgMoveInWrongStatus) @@ -898,7 +897,6 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForNavyCoastGuardAndMar }) suite.Run("Filters out moves with no PPM shipment", func() { - moveWithHHG := getSubmittedMove(suite, true, models.AffiliationCOASTGUARD) factory.BuildMTOShipment(suite.DB(), []factory.Customization{ { From 0f5b449b91ac7f9c23f1e1424ab638e6475bec71 Mon Sep 17 00:00:00 2001 From: KonstanceH Date: Mon, 8 Jul 2024 20:48:16 +0000 Subject: [PATCH 10/12] last one --- pkg/services/order/order_fetcher_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/services/order/order_fetcher_test.go b/pkg/services/order/order_fetcher_test.go index b6f8dfda7bf..b9a9fab6748 100644 --- a/pkg/services/order/order_fetcher_test.go +++ b/pkg/services/order/order_fetcher_test.go @@ -878,6 +878,7 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForNavyCoastGuardAndMar }) suite.Run("Filters out moves with PPM shipments not in the status of NeedsApproval", func() { + cgMoveInWrongStatus := getSubmittedMove(suite, true, models.AffiliationCOASTGUARD) buildPPMShipmentCloseoutComplete(suite, cgMoveInWrongStatus) @@ -897,6 +898,7 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForNavyCoastGuardAndMar }) suite.Run("Filters out moves with no PPM shipment", func() { + moveWithHHG := getSubmittedMove(suite, true, models.AffiliationCOASTGUARD) factory.BuildMTOShipment(suite.DB(), []factory.Customization{ { From ed24664808ad7f301fcfedf4adb00fd662ce4928 Mon Sep 17 00:00:00 2001 From: KonstanceH Date: Mon, 8 Jul 2024 20:57:58 +0000 Subject: [PATCH 11/12] linter change --- pkg/services/order/order_fetcher_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/services/order/order_fetcher_test.go b/pkg/services/order/order_fetcher_test.go index b9a9fab6748..e44ce4730bf 100644 --- a/pkg/services/order/order_fetcher_test.go +++ b/pkg/services/order/order_fetcher_test.go @@ -878,7 +878,7 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForNavyCoastGuardAndMar }) suite.Run("Filters out moves with PPM shipments not in the status of NeedsApproval", func() { - + cgMoveInWrongStatus := getSubmittedMove(suite, true, models.AffiliationCOASTGUARD) buildPPMShipmentCloseoutComplete(suite, cgMoveInWrongStatus) @@ -898,7 +898,7 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForNavyCoastGuardAndMar }) suite.Run("Filters out moves with no PPM shipment", func() { - + moveWithHHG := getSubmittedMove(suite, true, models.AffiliationCOASTGUARD) factory.BuildMTOShipment(suite.DB(), []factory.Customization{ { From 4374f220eccadbad267d32469e124816fb451b6b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 13:26:17 +0000 Subject: [PATCH 12/12] Bump github.com/jarcoal/httpmock from 1.3.0 to 1.3.1 Bumps [github.com/jarcoal/httpmock](https://github.com/jarcoal/httpmock) from 1.3.0 to 1.3.1. - [Release notes](https://github.com/jarcoal/httpmock/releases) - [Commits](https://github.com/jarcoal/httpmock/compare/v1.3.0...v1.3.1) --- updated-dependencies: - dependency-name: github.com/jarcoal/httpmock dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e1bf0d6a7ef..e12bab64a3e 100644 --- a/go.mod +++ b/go.mod @@ -203,7 +203,7 @@ require ( github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect github.com/jackc/pgtype v1.14.0 // indirect github.com/jackc/pgx/v4 v4.18.2 // indirect - github.com/jarcoal/httpmock v1.3.0 + github.com/jarcoal/httpmock v1.3.1 github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/joho/godotenv v1.5.1 // indirect github.com/josharian/intern v1.0.0 // indirect diff --git a/go.sum b/go.sum index d83726c9823..b3cf1002289 100644 --- a/go.sum +++ b/go.sum @@ -377,8 +377,8 @@ github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0f github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/jarcoal/httpmock v1.3.0 h1:2RJ8GP0IIaWwcC9Fp2BmVi8Kog3v2Hn7VXM3fTd+nuc= -github.com/jarcoal/httpmock v1.3.0/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg= +github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInww= +github.com/jarcoal/httpmock v1.3.1/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg= github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8=