diff --git a/pkg/experiment/local/assignment_filter.go b/pkg/experiment/local/assignment_filter.go index 9fd07a1..ed223e6 100644 --- a/pkg/experiment/local/assignment_filter.go +++ b/pkg/experiment/local/assignment_filter.go @@ -19,6 +19,9 @@ func newAssignmentFilter(size int) *assignmentFilter { } func (f *assignmentFilter) shouldTrack(assignment *assignment) bool { + if len(*assignment.results) == 0 { + return false + } canonicalAssignment := assignment.Canonicalize() f.mu.Lock() track, found := f.cache.Get(canonicalAssignment) diff --git a/pkg/experiment/local/assignment_filter_test.go b/pkg/experiment/local/assignment_filter_test.go index d7639d6..ac9b75a 100644 --- a/pkg/experiment/local/assignment_filter_test.go +++ b/pkg/experiment/local/assignment_filter_test.go @@ -167,14 +167,14 @@ func TestEmptyResult(t *testing.T) { assignment2 := newAssignment(user1, results) assignment3 := newAssignment(user2, results) filter := newAssignmentFilter(100) - if !filter.shouldTrack(assignment1) { - t.Errorf("Assignment1 should be tracked") + if filter.shouldTrack(assignment1) { + t.Errorf("Assignment1 should not be tracked") } if filter.shouldTrack(assignment2) { t.Errorf("Assignment2 should not be tracked") } - if !filter.shouldTrack(assignment3) { - t.Errorf("Assignment3 should be tracked") + if filter.shouldTrack(assignment3) { + t.Errorf("Assignment3 should not be tracked") } }