Skip to content

Commit

Permalink
Refactor address functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sepisoltani committed Apr 30, 2024
1 parent 8456f91 commit a65728e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions providers/location/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strconv"
)

// Sample data for the different parts of the address
// Sample data for the different parts of the address.
var (
buildingNumbers = func() []string {
numbers := make([]string, 3)
Expand All @@ -33,8 +33,8 @@ func randomElement(items []string) string {
return items[rand.Intn(len(items))]
}

// RandomPersianAddress generates a random Persian address
func RandomPersianAddress() string {
// GeneratePersianAddress generates a random Persian address.
func (Location) GeneratePersianAddress() string {
// Construct the address from the parts
return fmt.Sprintf("%s %s %s %s %s %s %s",
cityPrefix,
Expand Down
7 changes: 4 additions & 3 deletions providers/location/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"testing"
)

// TestRandomPersianAddress verifies that the format of the generated address is correct.
func TestRandomPersianAddress(t *testing.T) {
address := RandomPersianAddress()
// TestGeneratePersianAddress verifies that the format of the generated address is correct.
func TestGeneratePersianAddress(t *testing.T) {
location := &Location{}
address := location.GeneratePersianAddress()
// Split the address into components based on spaces
parts := strings.Fields(address)

Expand Down
2 changes: 1 addition & 1 deletion providers/phonenumber/phonenumber_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

// TestGeneratePersianMobileNumber checks if the generated mobile phone number is correctly formatted.
func TestGeneratePersianMobileNumber(t *testing.T) {
phoneNumber := &phoneNumber{}
phoneNumber := &PhoneNumber{}
generatedNumber := phoneNumber.GeneratePersianMobileNumber()

if len(generatedNumber) != 11 {
Expand Down

0 comments on commit a65728e

Please sign in to comment.