khalyomede / khalyomede/faker

improvement: generate sets based on field annotations/attributes

Open
#2 4 comments 0 reactions 1 assignee Claimed by @khalyomede View on GitHub
enhancement
Dominant language
V
Stars
2
Forks
1
PR merge metrics
No merged PRs in 30d

Description

example:

```v

struct UserProfile {
pub mut:
first_name string @[fake_source: first_name]
last_name string @[fake_source: last_name]
company_name string @[fake_source: company_name]
email string @[fake_source: email_address]
phone string @[fake_source: phone_number]
ip string @[fake_source: ip_v4]
accept_meeting string @[fake_list: 'yes,maybe,no']
accepted_agb string @[fake_list: 'true,false']
}

fn test_generate_user_profiles() {
mut ftl := FakerTypedList{
helper: Faker{}
}

profiles := ftl.generate[UserProfile](10) or {
print(err)
[]UserProfile{}
}
assert profiles.len == 10

for profile in profiles {
assert profile.first_name.len > 0
assert profile.last_name.len > 0
assert profile.email.len > 0
assert profile.phone.len > 0
assert profile.company_name.len > 0
println('Generated: ${profile}')
}
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.