diff options
author | Michael Muré <batolettre@gmail.com> | 2021-04-04 15:49:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-04 15:49:16 +0200 |
commit | fc04af34f5d6dff930003cc1f27ead972d424324 (patch) | |
tree | 8b9750d46182fff88d72fcc891e89d5a79ed83b0 /misc/random_bugs | |
parent | 2055bd5d0afb534cc98cd11bd9802d66acbb0c8f (diff) | |
parent | cb9b06551ddc1fae33046733f79ede20f8d09f9a (diff) | |
download | git-bug-fc04af34f5d6dff930003cc1f27ead972d424324.tar.gz |
Merge pull request #532 from MichaelMure/dag-entity
Work towards a reusable entity datastructure + commit signature
Diffstat (limited to 'misc/random_bugs')
-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) } |