Skip to content

Commit 9f66c77

Browse files
jszrobertojelmersnoeck
authored andcommitted
Fix bug in ControlValue (#25)
1 parent 7696af0 commit 9f66c77

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

experiment.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,16 @@ func (e *Experiment) runSequential(cChan chan *Observation) {
196196
func (e *Experiment) conclude() {
197197
control := e.observations["control"]
198198

199+
for _, o := range e.observations {
200+
if o.Error == nil {
201+
if e.clean != nil {
202+
o.CleanValue = e.clean(o.Value)
203+
} else {
204+
o.CleanValue = o.Value
205+
}
206+
}
207+
}
208+
199209
if e.compare != nil {
200210
for k, o := range e.observations {
201211
if o.Error == nil {
@@ -205,21 +215,11 @@ func (e *Experiment) conclude() {
205215
}
206216

207217
o.Success = e.compare(control.Value, o.Value)
218+
o.ControlValue = control.CleanValue
208219
}
209220
}
210221
}
211222

212-
for _, o := range e.observations {
213-
if o.Error == nil {
214-
if e.clean != nil {
215-
o.CleanValue = e.clean(o.Value)
216-
} else {
217-
o.CleanValue = o.Value
218-
}
219-
}
220-
o.ControlValue = control.CleanValue
221-
}
222-
223223
if e.Config.Publisher != nil {
224224
for _, o := range e.observations {
225225
e.Config.Publisher.Publish(*o)

experiment_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ func TestRun_Sequential(t *testing.T) {
5656

5757
t.Run("it should record the clean control", func(t *testing.T) {
5858
pub.fnc = func(o experiment.Observation) {
59-
if o.Name != "control" {
60-
fmt.Printf("%+v\n", o)
59+
if o.Name != "control" && o.Error == nil {
6160
if o.Panic == nil && o.ControlValue.(string) != "Cleaned control" {
6261
t.Errorf("Expected value to be '%s', got '%s'", "Cleaned Control", o.ControlValue.(string))
6362
}

0 commit comments

Comments
 (0)