Skip to content

Commit

Permalink
Fixturestore iterator (#25)
Browse files Browse the repository at this point in the history
* add fixture operation iterator

* fix load store on get iterator
  • Loading branch information
ebirukov authored Oct 3, 2023
1 parent 8f81db4 commit d4c9014
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions internal/pkg/generator/tmpl/octopus/fixturestore.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,20 @@ func GetUpdate{{$PublicStructName}}FixtureBy{{ $fieldNamePK }}(ctx context.Conte
return octopus.CreateUpdateFixture(obj.MockUpdate(ctx), wrappedTrigger), promiseIsUsed
}

func {{$PublicStructName}}StoreIterator() func(it func(any) error) error {
init{{$PublicStructName}}()

return func(it func(e any) error) error {
for _, e := range {{$PackageName}}Store {
if err := it(e); err != nil {
return err
}
}

return nil
}
}

{{ range $ind, $fstruct := $fields -}}
{{- range $i, $mut := $fstruct.Mutators -}}
{{ $customMutator := index $mutators $mut -}}
Expand Down Expand Up @@ -327,12 +341,12 @@ func (m {{ $PublicStructName }}By{{ $ind.Selector }}Mocker) ByFixture{{ $fieldNa
}
{{ else }}
if key == nil {
key = &{{ $PackageName }}.{{ $ind.Type }}{
key = &{{ $PackageName }}.{{ $ind.Type }}{
{{ range $_, $fieldNum := $ind.Fields }}
{{- $ifield := index $fields $fieldNum }}
{{ $ifield.Name }}: fix.Get{{ $ifield.Name }}(),
{{ end }}
}
}
} else {
{{ range $_, $fieldNum := $ind.Fields }}
{{- $ifield := index $fields $fieldNum }}
Expand Down

0 comments on commit d4c9014

Please sign in to comment.