Guest User

Untitled

a guest
Jun 24th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. package operator_test
  2.  
  3. import (
  4. "fmt"
  5. "testing"
  6. "time"
  7.  
  8. . "github.com/franela/goblin"
  9. )
  10.  
  11. func TestPickAdWithDataSet1(t *testing.T) {
  12. var g *G
  13. g = Goblin(t)
  14. g.Describe("Test PickAd 100000 times with DataSet 1 (2 Ads)\n"+
  15. " Ad1 has $10000 budget and 2 deliveries (MuzikOnline 50% and OneDream 50%).\n"+
  16. " Ad2 has $10000 budget and 2 deliveries (MuzikOnline 50% and OneDream 50%).\n"+
  17. " When request comes from MuzikOnline\n", func() {
  18. var adChances []operator.AdChance
  19. adChances = operator.GetAdChances("MuzikOnline", dataset1)
  20. var adCount map[string]int64
  21. adCount = make(map[string]int64)
  22. fmt.Println(time.Now().UnixNano())
  23. for index := 0; index < 100000; index++ {
  24. var ad models.Ad = operator.PickAd(adChances)
  25. adCount[ad.ID]++
  26. }
  27. fmt.Println(adCount["Ad1"])
  28. g.It("Ad1 should be near 50%", func() {
  29. var expected int = 2
  30. var actual int = len(adChances)
  31. g.Assert(expected).Equal(actual)
  32. })
  33. })
  34. }
Add Comment
Please, Sign In to add comment