diff options
Diffstat (limited to 'misc/random_bugs/create_random_bugs.go')
-rw-r--r-- | misc/random_bugs/create_random_bugs.go | 57 |
1 files changed, 7 insertions, 50 deletions
diff --git a/misc/random_bugs/create_random_bugs.go b/misc/random_bugs/create_random_bugs.go index 2de77722..a69918f4 100644 --- a/misc/random_bugs/create_random_bugs.go +++ b/misc/random_bugs/create_random_bugs.go @@ -111,54 +111,8 @@ func generateRandomBugsWithSeed(opts Options, seed int64) []*bug.Bug { return result } -func GenerateRandomOperationPacks(packNumber int, opNumber int) []*bug.OperationPack { - return GenerateRandomOperationPacksWithSeed(packNumber, opNumber, time.Now().UnixNano()) -} - -func GenerateRandomOperationPacksWithSeed(packNumber int, opNumber int, seed int64) []*bug.OperationPack { - // Note: this is a bit crude, only generate a Create + Comments - - panic("this piece of code needs to be updated to make sure that the identities " + - "are properly commit before usage. That is, generateRandomPersons() need to be called.") - - rand.Seed(seed) - fake.Seed(seed) - - result := make([]*bug.OperationPack, packNumber) - - for i := 0; i < packNumber; i++ { - opp := &bug.OperationPack{} - - var op bug.Operation - - op = bug.NewCreateOp( - randomPerson(), - time.Now().Unix(), - fake.Sentence(), - paragraphs(), - nil, - ) - - opp.Append(op) - - for j := 0; j < opNumber-1; j++ { - op = bug.NewAddCommentOp( - randomPerson(), - time.Now().Unix(), - paragraphs(), - nil, - ) - opp.Append(op) - } - - result[i] = opp - } - - return result -} - -func person() *identity.Identity { - return identity.NewIdentity(fake.FullName(), fake.EmailAddress()) +func person(repo repository.RepoClock) (*identity.Identity, error) { + return identity.NewIdentity(repo, fake.FullName(), fake.EmailAddress()) } var persons []*identity.Identity @@ -166,8 +120,11 @@ var persons []*identity.Identity func generateRandomPersons(repo repository.ClockedRepo, n int) { persons = make([]*identity.Identity, n) for i := range persons { - p := person() - err := p.Commit(repo) + p, err := person(repo) + if err != nil { + panic(err) + } + err = p.Commit(repo) if err != nil { panic(err) } |