Skip to content

Commit

Permalink
Fix bug in ControlValue (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
jszroberto authored and jelmersnoeck committed Dec 20, 2019
1 parent 7696af0 commit 9f66c77
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
22 changes: 11 additions & 11 deletions experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,16 @@ func (e *Experiment) runSequential(cChan chan *Observation) {
func (e *Experiment) conclude() {
control := e.observations["control"]

for _, o := range e.observations {
if o.Error == nil {
if e.clean != nil {
o.CleanValue = e.clean(o.Value)
} else {
o.CleanValue = o.Value
}
}
}

if e.compare != nil {
for k, o := range e.observations {
if o.Error == nil {
Expand All @@ -205,21 +215,11 @@ func (e *Experiment) conclude() {
}

o.Success = e.compare(control.Value, o.Value)
o.ControlValue = control.CleanValue
}
}
}

for _, o := range e.observations {
if o.Error == nil {
if e.clean != nil {
o.CleanValue = e.clean(o.Value)
} else {
o.CleanValue = o.Value
}
}
o.ControlValue = control.CleanValue
}

if e.Config.Publisher != nil {
for _, o := range e.observations {
e.Config.Publisher.Publish(*o)
Expand Down
3 changes: 1 addition & 2 deletions experiment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ func TestRun_Sequential(t *testing.T) {

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

0 comments on commit 9f66c77

Please sign in to comment.