Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package operator_test
- import (
- "fmt"
- "testing"
- "time"
- . "github.com/franela/goblin"
- )
- func TestPickAdWithDataSet1(t *testing.T) {
- var g *G
- g = Goblin(t)
- g.Describe("Test PickAd 100000 times with DataSet 1 (2 Ads)\n"+
- " Ad1 has $10000 budget and 2 deliveries (MuzikOnline 50% and OneDream 50%).\n"+
- " Ad2 has $10000 budget and 2 deliveries (MuzikOnline 50% and OneDream 50%).\n"+
- " When request comes from MuzikOnline\n", func() {
- var adChances []operator.AdChance
- adChances = operator.GetAdChances("MuzikOnline", dataset1)
- var adCount map[string]int64
- adCount = make(map[string]int64)
- fmt.Println(time.Now().UnixNano())
- for index := 0; index < 100000; index++ {
- var ad models.Ad = operator.PickAd(adChances)
- adCount[ad.ID]++
- }
- fmt.Println(adCount["Ad1"])
- g.It("Ad1 should be near 50%", func() {
- var expected int = 2
- var actual int = len(adChances)
- g.Assert(expected).Equal(actual)
- })
- })
- }
Add Comment
Please, Sign In to add comment