Skip to content

Commit

Permalink
Fix NoSuchElementException in uk.address.city
Browse files Browse the repository at this point in the history
Also fixes same issue in uk.company.name which was calling a non-default
key from address.
  • Loading branch information
serpro69 committed May 19, 2024
1 parent 120d2c7 commit 968c85f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ class AddressIT : DescribeSpec({
address("uk").citySuffix() shouldBe ""
}
}

context("non-default key reference - gh #239") {
repeat(10) {
it("city() does NOT throw NoSuchElementException run#$it") {
shouldNotThrow<NoSuchElementException> { address("uk").city() }
}
}
}
}

context("nb-NO locale") {
Expand Down
13 changes: 8 additions & 5 deletions core/src/main/resources/locales/uk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ uk:
- Стрийська
- Вузька
- Староміська
city_name:
# NB! don't remove city_name anchor
# See https://github.com/serpro69/kotlin-faker/issues/239
city_name: &city_name
- Алчевськ
- Артемівськ
- Бердичів
Expand Down Expand Up @@ -341,8 +343,9 @@ uk:
- Ялта
city_prefix: []
city_suffix: []
city:
- "#{city_name}"
# NB! don't change anchor reference
# See https://github.com/serpro69/kotlin-faker/issues/239
city: *city_name
street_name:
- "#{feminine_street_prefix} #{feminine_street_title}"
- "#{masculine_street_prefix} #{masculine_street_title}"
Expand Down Expand Up @@ -1784,8 +1787,8 @@ uk:
- "#{prefix} #{Name.female_first_name}"
- "#{prefix} #{Name.male_first_name}"
- "#{prefix} #{Name.male_last_name}"
- "#{prefix} #{Address.city_name}#{product}#{suffix}"
- "#{prefix} #{Address.city_name}#{suffix}"
- "#{prefix} #{Address.city}#{product}#{suffix}" # NB! do not change, see #239
- "#{prefix} #{Address.city}#{suffix}" # NB! do not change, see #239
music:
instruments:
- Електрична гітара
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ class CompanyIT : DescribeSpec({
describe("Company Provider") {
val company: (locale: String) -> Company = { faker { fakerConfig { locale = it } }.company }

context("uk locale") {
it("should generate a valid name") {
shouldNotThrow<NoSuchElementException> { company("uk").name() shouldNotBe "" }
}
}

context("ja locale") {
it("should generate a valid name") {
shouldNotThrow<NoSuchElementException> { company("ja").name() shouldNotBe "" }
Expand Down

0 comments on commit 968c85f

Please sign in to comment.