code quality
This commit is contained in:
parent
14d95a2ec9
commit
f9ae0870d6
16
main_test.go
16
main_test.go
@ -913,7 +913,7 @@ func TestSaveAssociations(t *testing.T) {
|
|||||||
|
|
||||||
// owner address should be created, place address should be reused
|
// owner address should be created, place address should be reused
|
||||||
place1 := &Place{
|
place1 := &Place{
|
||||||
PlaceAddressId: placeAddress.ID,
|
PlaceAddressID: placeAddress.ID,
|
||||||
PlaceAddress: placeAddress,
|
PlaceAddress: placeAddress,
|
||||||
OwnerAddress: ownerAddress1,
|
OwnerAddress: ownerAddress1,
|
||||||
}
|
}
|
||||||
@ -925,13 +925,13 @@ func TestSaveAssociations(t *testing.T) {
|
|||||||
|
|
||||||
// owner address should be created again, place address should be reused
|
// owner address should be created again, place address should be reused
|
||||||
place2 := &Place{
|
place2 := &Place{
|
||||||
PlaceAddressId: placeAddress.ID,
|
PlaceAddressID: placeAddress.ID,
|
||||||
PlaceAddress: &Address{
|
PlaceAddress: &Address{
|
||||||
ID: 777,
|
ID: 777,
|
||||||
Address1: "address1",
|
Address1: "address1",
|
||||||
},
|
},
|
||||||
OwnerAddress: ownerAddress2,
|
OwnerAddress: ownerAddress2,
|
||||||
OwnerAddressId: 778,
|
OwnerAddressID: 778,
|
||||||
}
|
}
|
||||||
err = db.Create(place2).Error
|
err = db.Create(place2).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -941,8 +941,8 @@ func TestSaveAssociations(t *testing.T) {
|
|||||||
|
|
||||||
count := 0
|
count := 0
|
||||||
db.Model(&Place{}).Where(&Place{
|
db.Model(&Place{}).Where(&Place{
|
||||||
PlaceAddressId: placeAddress.ID,
|
PlaceAddressID: placeAddress.ID,
|
||||||
OwnerAddressId: ownerAddress1.ID,
|
OwnerAddressID: ownerAddress1.ID,
|
||||||
}).Count(&count)
|
}).Count(&count)
|
||||||
if count != 1 {
|
if count != 1 {
|
||||||
t.Errorf("only one instance of (%d, %d) should be available, found: %d",
|
t.Errorf("only one instance of (%d, %d) should be available, found: %d",
|
||||||
@ -950,8 +950,8 @@ func TestSaveAssociations(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
db.Model(&Place{}).Where(&Place{
|
db.Model(&Place{}).Where(&Place{
|
||||||
PlaceAddressId: placeAddress.ID,
|
PlaceAddressID: placeAddress.ID,
|
||||||
OwnerAddressId: ownerAddress2.ID,
|
OwnerAddressID: ownerAddress2.ID,
|
||||||
}).Count(&count)
|
}).Count(&count)
|
||||||
if count != 1 {
|
if count != 1 {
|
||||||
t.Errorf("only one instance of (%d, %d) should be available, found: %d",
|
t.Errorf("only one instance of (%d, %d) should be available, found: %d",
|
||||||
@ -959,7 +959,7 @@ func TestSaveAssociations(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
db.Model(&Place{}).Where(&Place{
|
db.Model(&Place{}).Where(&Place{
|
||||||
PlaceAddressId: placeAddress.ID,
|
PlaceAddressID: placeAddress.ID,
|
||||||
}).Count(&count)
|
}).Count(&count)
|
||||||
if count != 2 {
|
if count != 2 {
|
||||||
t.Errorf("two instances of (%d) should be available, found: %d",
|
t.Errorf("two instances of (%d) should be available, found: %d",
|
||||||
|
@ -120,9 +120,9 @@ type Company struct {
|
|||||||
|
|
||||||
type Place struct {
|
type Place struct {
|
||||||
Id int64
|
Id int64
|
||||||
PlaceAddressId int
|
PlaceAddressID int
|
||||||
PlaceAddress *Address `gorm:"save_associations:false"`
|
PlaceAddress *Address `gorm:"save_associations:false"`
|
||||||
OwnerAddressId int
|
OwnerAddressID int
|
||||||
OwnerAddress *Address `gorm:"save_associations:true"`
|
OwnerAddress *Address `gorm:"save_associations:true"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user