Skip to content

Commit

Permalink
fixes for generated tests (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuval-k authored Dec 5, 2018
1 parent 7f3c7d7 commit 798acc5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion pkg/code-generator/codegen/templates/event_loop_test_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var ResourceGroupEventLoopTestTemplate = template.Must(template.New("resource_gr
import (
"context"
"time"
"sync"
{{ .Imports }}
. "github.com/onsi/ginkgo"
Expand Down Expand Up @@ -52,16 +53,25 @@ var _ = Describe("{{ .GoName }}EventLoop", func() {
el := New{{ .GoName }}EventLoop(emitter, sync)
_, err := el.Run([]string{namespace}, clients.WatchOpts{})
Expect(err).NotTo(HaveOccurred())
Eventually(func() bool { return sync.synced }, time.Second).Should(BeTrue())
Eventually(sync.Synced, 5*time.Second).Should(BeTrue())
})
})
type mock{{ .GoName }}Syncer struct {
synced bool
mutex sync.Mutex
}
func (s *mock{{ .GoName }}Syncer) Synced() bool {
s.mutex.Lock()
defer s.mutex.Unlock()
return s.synced
}
func (s *mock{{ .GoName }}Syncer) Sync(ctx context.Context, snap *{{ .GoName }}Snapshot) error {
s.mutex.Lock()
s.synced = true
s.mutex.Unlock()
return nil
}
`))
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/solo-io/solo-kit/pkg/api/v1/clients/factory"
"github.com/solo-io/solo-kit/test/helpers"
"github.com/solo-io/solo-kit/pkg/api/v1/clients"
"github.com/solo-io/solo-kit/pkg/api/v1/resources"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ import (
kuberc "github.com/solo-io/solo-kit/pkg/api/v1/clients/kube"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
{{- if $needs_kube_client }}
"k8s.io/client-go/kubernetes"
{{- end }}
)
var _ = Describe("{{ upper_camel .Project.Version }}Emitter", func() {
Expand Down

0 comments on commit 798acc5

Please sign in to comment.