Skip to content

Commit

Permalink
Merge branch 'main' into main-b-21683
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljordan-caci authored Jan 3, 2025
2 parents 75e484f + 8a3c33d commit fdcc4ab
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 55 deletions.
1 change: 1 addition & 0 deletions migrations/app/migrations_manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,7 @@
20241203024453_add_ppm_max_incentive_column.up.sql
20241204155919_update_ordering_proc.up.sql
20241204210208_retroactive_update_of_ppm_max_and_estimated_incentives_prd.up.sql
20241218201833_add_PPPO_BASE_ELIZABETH.up.sql
20241217163231_update_duty_locations_bad_zips.up.sql
20241217180136_add_AK_zips_to_zip3_distances.up.sql
20241220171035_add_additional_AK_zips_to_zip3_distances.up.sql
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- Local test migration.
-- This will be run on development environments.
-- It should mirror what you intend to apply on loadtest/demo/exp/stg/prd
-- DO NOT include any sensitive data.
INSERT INTO addresses
(id, street_address_1, street_address_2, city, state, postal_code, created_at, updated_at, street_address_3, county, is_oconus, country_id, us_post_region_cities_id)
VALUES('6f321986-86ff-4e16-9ec3-5fc561deaf9e', '1664 Weeksville Rd', '', 'Elizabeth City', 'NC', '27909', now(), now(), '', 'PASQUOTANK', false, '791899e6-cd77-46f2-981b-176ecb8d7098', 'd8541f35-2c8b-4bee-8fca-cb67582ce34e');


INSERT INTO transportation_offices
(id, shipping_office_id, "name", address_id, latitude, longitude, hours, services, note, created_at, updated_at, gbloc, provides_ppm_closeout)
VALUES('4cd300fb-0a45-478a-8f55-5aba4c5921b3',null, 'PPPO Base Elizabeth City','6f321986-86ff-4e16-9ec3-5fc561deaf9e',36.302952, -76.245804, '', '', '', now(), now(), 'BGNC'::character varying, false);


INSERT INTO office_phone_lines
(id, transportation_office_id, "number", "label", is_dsn_number, "type", created_at, updated_at)
VALUES('f8661e7a-24c4-467a-9f55-9004ffac472e', '4cd300fb-0a45-478a-8f55-5aba4c5921b3', '(252)335-6362', '', false, 'voice'::text, now(), now());

insert into office_emails
(id, transportation_office_id, email, created_at, updated_at)
values
('6a46978f-9ea2-4535-8f80-dae8e6a15595', '4cd300fb-0a45-478a-8f55-5aba4c5921b3', 'D05-SMB-BaseElizabethCity-HHG@uscg.mil', now(), now());

INSERT INTO duty_locations
(id, "name", affiliation, address_id, created_at, updated_at, transportation_office_id, provides_services_counseling)
VALUES('4b6c3be8-961d-44c6-b0f7-bd6c205cc3f6', 'PPPO Base Elizabeth City', 'USCG', '6f321986-86ff-4e16-9ec3-5fc561deaf9e', now(), now(), '4cd300fb-0a45-478a-8f55-5aba4c5921b3', true);

INSERT INTO duty_location_names
(id, "name", duty_location_id, created_at, updated_at)
VALUES('837a16cd-5dbc-48af-a987-7ec238e7b186', 'PPPO Base Elizabeth City', '4b6c3be8-961d-44c6-b0f7-bd6c205cc3f6', now(), now());
37 changes: 12 additions & 25 deletions pkg/models/port_location.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,24 @@ package models
import (
"time"

"github.com/gobuffalo/pop/v6"
"github.com/gobuffalo/validate/v3"
"github.com/gobuffalo/validate/v3/validators"
"github.com/gofrs/uuid"
)

type PortLocation struct {
ID uuid.UUID `json:"id" db:"id"`
PortId uuid.UUID `json:"port_id" db:"port_id"`
Port Port `belongs_to:"port_locations" fk_id:"port_id"`
CitiesId uuid.UUID `json:"cities_id" db:"cities_id"`
City City `belongs_to:"re_cities" fk_id:"cities_id"`
UsPostRegionCitiesId uuid.UUID `json:"us_post_region_cities_id" db:"us_post_region_cities_id"`
UsPostRegionCity UsPostRegionCity `belongs_to:"us_post_region_cities" fk_id:"us_post_region_cities_id"`
CountryId uuid.UUID `json:"country_id" db:"country_id"`
Country Country `belongs_to:"re_countries" fk_id:"country_id"`
IsActive *bool `json:"is_active" db:"is_active"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
ID uuid.UUID `json:"id" db:"id" rw:"r"`
PortId uuid.UUID `json:"port_id" db:"port_id" rw:"r"`
Port Port `belongs_to:"port_locations" fk_id:"port_id" rw:"r"`
CitiesId uuid.UUID `json:"cities_id" db:"cities_id" rw:"r"`
City City `belongs_to:"re_cities" fk_id:"cities_id" rw:"r"`
UsPostRegionCitiesId uuid.UUID `json:"us_post_region_cities_id" db:"us_post_region_cities_id" rw:"r"`
UsPostRegionCity UsPostRegionCity `belongs_to:"us_post_region_cities" fk_id:"us_post_region_cities_id" rw:"r"`
CountryId uuid.UUID `json:"country_id" db:"country_id" rw:"r"`
Country Country `belongs_to:"re_countries" fk_id:"country_id" rw:"r"`
IsActive *bool `json:"is_active" db:"is_active" rw:"r"`
CreatedAt time.Time `json:"created_at" db:"created_at" rw:"r"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at" rw:"r"`
}

func (l PortLocation) TableName() string {
return "port_locations"
}

// Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method.
func (p *PortLocation) Validate(_ *pop.Connection) (*validate.Errors, error) {
return validate.Validate(
&validators.UUIDIsPresent{Field: p.PortId, Name: "PortID"},
&validators.UUIDIsPresent{Field: p.CitiesId, Name: "CitiesID"},
&validators.UUIDIsPresent{Field: p.UsPostRegionCitiesId, Name: "UsPostRegionCitiesID"},
&validators.UUIDIsPresent{Field: p.CountryId, Name: "CountryID"},
), nil
}
44 changes: 14 additions & 30 deletions pkg/models/port_location_test.go
Original file line number Diff line number Diff line change
@@ -1,42 +1,26 @@
package models_test

import (
"time"
"github.com/transcom/mymove/pkg/factory"
)

"github.com/gofrs/uuid"
func (suite *ModelSuite) TestPortLocation() {
suite.Run("Port location has correct fields", func() {

"github.com/transcom/mymove/pkg/models"
)
portLocation := factory.FetchPortLocation(suite.DB(), nil, nil)

func (suite *ModelSuite) TestPortLocationValidation() {
suite.Run("test valid PortLocation", func() {
validPortLocation := models.PortLocation{
ID: uuid.Must(uuid.NewV4()),
PortId: uuid.Must(uuid.NewV4()),
CitiesId: uuid.Must(uuid.NewV4()),
UsPostRegionCitiesId: uuid.Must(uuid.NewV4()),
CountryId: uuid.Must(uuid.NewV4()),
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
}
expErrors := map[string][]string{}
suite.verifyValidationErrors(&validPortLocation, expErrors)
suite.NotNil(portLocation)
suite.Equal(portLocation.PortId, portLocation.Port.ID)
suite.Equal(portLocation.CitiesId, portLocation.City.ID)
suite.Equal(portLocation.UsPostRegionCitiesId, portLocation.UsPostRegionCity.ID)
suite.Equal(portLocation.CountryId, portLocation.Country.ID)
})

suite.Run("test missing required fields", func() {
invalidPortLocation := models.PortLocation{
ID: uuid.Must(uuid.NewV4()),
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
}
suite.Run("Port location table name is correct", func() {

expErrors := map[string][]string{
"port_id": {"PortID can not be blank."},
"cities_id": {"CitiesID can not be blank."},
"us_post_region_cities_id": {"UsPostRegionCitiesID can not be blank."},
"country_id": {"CountryID can not be blank."},
}
portLocation := factory.FetchPortLocation(suite.DB(), nil, nil)

suite.verifyValidationErrors(&invalidPortLocation, expErrors)
suite.NotNil(portLocation)
suite.Equal("port_locations", portLocation.TableName())
})
}

0 comments on commit fdcc4ab

Please sign in to comment.