-
Notifications
You must be signed in to change notification settings - Fork 1
/
fixtures_test.go
68 lines (55 loc) · 1.68 KB
/
fixtures_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package attribution
import (
"fmt"
"math/big"
)
// touchpointFixture provides a fixture for a slice of Touchpoint objects.
func touchpointFixture() []Touchpoint {
var touchpoints []Touchpoint
for i := 0; i < 10; i++ {
touchpoints = append(touchpoints, Touchpoint{fmt.Sprintf("Touchpoint %d", i)})
}
return touchpoints
}
// contributionFixture provides a fixture for a slice of Contribution objects.
func contributionFixture() []Contribution {
var contributions []Contribution
touchpoints := touchpointFixture()
for i := 0; i < 5; i++ {
for j := 0; j <= 5; j++ {
touchpointList := Touchpoints(touchpoints[i : i+j])
contribution := Contribution{
Touchpoints: touchpointList,
Value: *new(big.Float).SetFloat64(float64(100 * i)),
}
contributions = append(contributions, contribution)
}
}
return contributions
}
// contributionSetFixture provides a fixture for a slice of ContributionSet objects.
func contributionSetFixture() []ContributionSet {
var contributions []ContributionSet
touchpoints := touchpointFixture()
for i := 0; i < 5; i++ {
for j := 0; j <= 5; j++ {
touchpointMap := make(map[Touchpoint]struct{})
for _, touchpoint := range touchpoints[i : i+j] {
touchpointMap[touchpoint] = struct{}{}
}
contribution := ContributionSet{
Touchpoints: touchpointMap,
Value: *new(big.Float).SetFloat64(float64(100 * i)),
}
contributions = append(contributions, contribution)
}
}
return contributions
}
// coalitionFixture provides a coaltion fixture.
func coalitionFixture() map[Touchpoint]struct{} {
return map[Touchpoint]struct{}{
Touchpoint{"Touchpoint 1"}: struct{}{},
Touchpoint{"Touchpoint 2"}: struct{}{},
}
}