Skip to content

Commit

Permalink
Merge branch 'main' into MAIN-B-21942
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljordan-caci authored Jan 8, 2025
2 parents 1ac32cd + d60eb89 commit 574ffd9
Show file tree
Hide file tree
Showing 47 changed files with 2,988 additions and 100 deletions.
1 change: 1 addition & 0 deletions migrations/app/migrations_manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,7 @@
20241218201833_add_PPPO_BASE_ELIZABETH.up.sql
20241220171035_add_additional_AK_zips_to_zip3_distances.up.sql
20241220213134_add_destination_gbloc_db_function.up.sql
20241226173330_add_intl_param_values_to_service_params_table.up.sql
20241227153723_remove_empty_string_emplid_values.up.sql
20241227202424_insert_transportation_offices_camp_pendelton.up.sql
20241230190638_remove_AK_zips_from_zip3.up.sql
Expand Down

Large diffs are not rendered by default.

34 changes: 25 additions & 9 deletions pkg/factory/address_factory.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package factory

import (
"database/sql"

"github.com/gobuffalo/pop/v6"
"github.com/gofrs/uuid"

"github.com/transcom/mymove/pkg/models"
"github.com/transcom/mymove/pkg/testdatagen"
Expand All @@ -24,15 +27,17 @@ func BuildAddress(db *pop.Connection, customs []Customization, traits []Trait) m
}

// Create default Address
beverlyHillsUsprc := uuid.FromStringOrNil("3b9f0ae6-3b2b-44a6-9fcd-8ead346648c4")
address := models.Address{
StreetAddress1: "123 Any Street",
StreetAddress2: models.StringPointer("P.O. Box 12345"),
StreetAddress3: models.StringPointer("c/o Some Person"),
City: "Beverly Hills",
State: "CA",
PostalCode: "90210",
County: models.StringPointer("LOS ANGELES"),
IsOconus: models.BoolPointer(false),
StreetAddress1: "123 Any Street",
StreetAddress2: models.StringPointer("P.O. Box 12345"),
StreetAddress3: models.StringPointer("c/o Some Person"),
City: "Beverly Hills",
State: "CA",
PostalCode: "90210",
County: models.StringPointer("LOS ANGELES"),
IsOconus: models.BoolPointer(false),
UsPostRegionCityID: &beverlyHillsUsprc,
}

// Find/create the Country if customization is provided
Expand All @@ -56,7 +61,7 @@ func BuildAddress(db *pop.Connection, customs []Customization, traits []Trait) m
// Overwrite values with those from customizations
testdatagen.MergeModels(&address, cAddress)

// This helps assign counties when the factory is called for seed data or tests
// This helps assign counties & us_post_region_cities_id values when the factory is called for seed data or tests
// Additionally, also only run if not 90210. 90210's county is by default populated
if db != nil && address.PostalCode != "90210" {
county, err := models.FindCountyByZipCode(db, address.PostalCode)
Expand All @@ -72,6 +77,17 @@ func BuildAddress(db *pop.Connection, customs []Customization, traits []Trait) m
address.County = models.StringPointer("db nil when created")
}

if db != nil && address.PostalCode != "90210" && cAddress.UsPostRegionCityID == nil {
usprc, err := models.FindByZipCode(db, address.PostalCode)
if err != nil && err != sql.ErrNoRows {
address.UsPostRegionCityID = nil
address.UsPostRegionCity = nil
} else if usprc.ID != uuid.Nil {
address.UsPostRegionCityID = &usprc.ID
address.UsPostRegionCity = usprc
}
}

// If db is false, it's a stub. No need to create in database.
if db != nil {
mustCreate(db, &address)
Expand Down
1 change: 1 addition & 0 deletions pkg/factory/address_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (suite *FactorySuite) TestBuildAddress() {
suite.Equal(defaultPostalCode, address.PostalCode)
suite.Equal(country.ID, *address.CountryId)
suite.Equal(defaultCounty, *address.County)
suite.NotNil(*address.UsPostRegionCityID)
})

suite.Run("Successful creation of an address with customization", func() {
Expand Down
4 changes: 2 additions & 2 deletions pkg/gen/primeapi/embedded_spec.go

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 574ffd9

Please sign in to comment.