add username

master
Joshua Herring 4 weeks ago
parent 0faa0e3a5d
commit 0a6f6c00f1

@ -535,6 +535,7 @@ func GenerateUserData(config Config) []User {
LastName: gofakeit.LastName(), LastName: gofakeit.LastName(),
Status: weightedStatuses[rand.Intn(len(weightedStatuses))], Status: weightedStatuses[rand.Intn(len(weightedStatuses))],
ExamID: examIDs[i], ExamID: examIDs[i],
Username: gofakeit.Username(),
APIKey: strings.ReplaceAll(gofakeit.UUID(), "-", ""), APIKey: strings.ReplaceAll(gofakeit.UUID(), "-", ""),
PasswordHash: gofakeit.Password(true, true, true, true, false, 16), PasswordHash: gofakeit.Password(true, true, true, true, false, 16),
} }
@ -553,11 +554,11 @@ func SaveGeneratedUsers(users []User) {
defer f.Close() defer f.Close()
w := csv.NewWriter(f) w := csv.NewWriter(f)
if err := w.Write([]string{"uid", "first_name", "last_name", "status", "exam_id", "api_key", "password_hash"}); err != nil { if err := w.Write([]string{"uid", "first_name", "last_name", "status", "exam_id", "username", "api_key", "password_hash"}); err != nil {
log.Fatalf("failed to write csv header: %v", err) log.Fatalf("failed to write csv header: %v", err)
} }
for _, u := range users { for _, u := range users {
if err := w.Write([]string{u.UID, u.FirstName, u.LastName, u.Status, u.ExamID, u.APIKey, u.PasswordHash}); err != nil { if err := w.Write([]string{u.UID, u.FirstName, u.LastName, u.Status, u.ExamID, u.Username, u.APIKey, u.PasswordHash}); err != nil {
log.Fatalf("failed to write csv row: %v", err) log.Fatalf("failed to write csv row: %v", err)
} }
} }

@ -0,0 +1 @@
Add Username to the GenerateUserData function using gofakeit. Also add this to SaveGeneratedUsers.
Loading…
Cancel
Save