Skip to content

Commit 7696af0

Browse files
authored
Merge pull request #22 from jszroberto/include-control-result-in-candidate
Add control clean value to candidate observations
2 parents 403547c + 170ed3f commit 7696af0

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

experiment.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ func (e *Experiment) conclude() {
217217
o.CleanValue = o.Value
218218
}
219219
}
220+
o.ControlValue = control.CleanValue
220221
}
221222

222223
if e.Config.Publisher != nil {

experiment_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,20 @@ func TestRun_Sequential(t *testing.T) {
5454
exp.Run()
5555
})
5656

57-
t.Run("it should record the clean", func(t *testing.T) {
57+
t.Run("it should record the clean control", func(t *testing.T) {
58+
pub.fnc = func(o experiment.Observation) {
59+
if o.Name != "control" {
60+
fmt.Printf("%+v\n", o)
61+
if o.Panic == nil && o.ControlValue.(string) != "Cleaned control" {
62+
t.Errorf("Expected value to be '%s', got '%s'", "Cleaned Control", o.ControlValue.(string))
63+
}
64+
}
65+
}
66+
67+
exp.Run()
68+
})
69+
70+
t.Run("it should record the clean control value", func(t *testing.T) {
5871
pub.fnc = func(o experiment.Observation) {
5972
if o.Panic == nil && o.Error == nil && o.Success {
6073
cleaned := fmt.Sprintf("Cleaned %s", o.Value.(string))

observation.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import "time"
44

55
// Observation represents the outcome of a candidate that has run.
66
type Observation struct {
7-
Duration time.Duration
8-
Error error
9-
Success bool
10-
Name string
11-
Panic interface{}
12-
Value interface{}
13-
CleanValue interface{}
7+
Duration time.Duration
8+
Error error
9+
Success bool
10+
Name string
11+
Panic interface{}
12+
Value interface{}
13+
CleanValue interface{}
14+
ControlValue interface{}
1415
}

0 commit comments

Comments
 (0)