(name string, config Config)
| 27 | } |
| 28 | |
| 29 | func GetUser(name string, config Config) *User { |
| 30 | var ( |
| 31 | birthday = time.Now().Round(time.Second) |
| 32 | user = User{ |
| 33 | Name: name, |
| 34 | Age: 18, |
| 35 | Birthday: &birthday, |
| 36 | } |
| 37 | ) |
| 38 | |
| 39 | if config.Account { |
| 40 | user.Account = Account{Number: name + "_account"} |
| 41 | } |
| 42 | |
| 43 | for i := 0; i < config.Pets; i++ { |
| 44 | user.Pets = append(user.Pets, &Pet{Name: name + "_pet_" + strconv.Itoa(i+1)}) |
| 45 | } |
| 46 | |
| 47 | for i := 0; i < config.Toys; i++ { |
| 48 | user.Toys = append(user.Toys, Toy{Name: name + "_toy_" + strconv.Itoa(i+1)}) |
| 49 | } |
| 50 | |
| 51 | for i := 0; i < config.Tools; i++ { |
| 52 | user.Tools = append(user.Tools, Tools{Name: name + "_tool_" + strconv.Itoa(i+1)}) |
| 53 | } |
| 54 | |
| 55 | if config.Company { |
| 56 | user.Company = Company{Name: "company-" + name} |
| 57 | } |
| 58 | |
| 59 | if config.Manager { |
| 60 | user.Manager = GetUser(name+"_manager", Config{}) |
| 61 | } |
| 62 | |
| 63 | for i := 0; i < config.Team; i++ { |
| 64 | user.Team = append(user.Team, *GetUser(name+"_team_"+strconv.Itoa(i+1), Config{})) |
| 65 | } |
| 66 | |
| 67 | for i := 0; i < config.Languages; i++ { |
| 68 | name := name + "_locale_" + strconv.Itoa(i+1) |
| 69 | language := Language{Code: name, Name: name} |
| 70 | user.Languages = append(user.Languages, language) |
| 71 | } |
| 72 | |
| 73 | for i := 0; i < config.Friends; i++ { |
| 74 | user.Friends = append(user.Friends, GetUser(name+"_friend_"+strconv.Itoa(i+1), Config{})) |
| 75 | } |
| 76 | |
| 77 | if config.NamedPet { |
| 78 | user.NamedPet = &Pet{Name: name + "_namepet"} |
| 79 | } |
| 80 | |
| 81 | return &user |
| 82 | } |
| 83 | |
| 84 | func CheckPetUnscoped(t *testing.T, pet Pet, expect Pet) { |
| 85 | doCheckPet(t, pet, expect, true) |
no outgoing calls
no test coverage detected