Advertisement
Guest User

Untitled

a guest
Aug 26th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. package ginkgoparallel_test
  2.  
  3. import (
  4. "fmt"
  5. "math/rand"
  6. "time"
  7.  
  8. g "github.com/onsi/ginkgo"
  9. )
  10.  
  11. func init() {
  12. rand.Seed(time.Now().Unix())
  13. }
  14.  
  15. type framework struct {
  16. namespace string
  17. }
  18.  
  19. func (f *framework) BeforeEach() {
  20. f.namespace = fmt.Sprintf("ns-%d", rand.Int())
  21. }
  22.  
  23. var _ = g.Describe("d1", func() {
  24. f := &framework{}
  25. g.BeforeEach(f.BeforeEach)
  26. g.AfterEach(func() {
  27. fmt.Printf("%s %s", g.CurrentGinkgoTestDescription().TestText, f.namespace)
  28. })
  29.  
  30. makeTest := func(i int) {
  31. g.Describe(fmt.Sprintf("t%d", i), func() {
  32. g.It(fmt.Sprintf("should t%d", i), func() {
  33. fmt.Printf("NODE=%d\n", g.GinkgoParallelNode())
  34. })
  35. })
  36. }
  37. for i := 0; i < 20; i++ {
  38. makeTest(i)
  39. }
  40. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement