diff --git a/engine/history_test.go b/engine/history_test.go index 0d0355986..e7541f5cf 100644 --- a/engine/history_test.go +++ b/engine/history_test.go @@ -27,7 +27,7 @@ import ( func TestHistoryRatinPlans(t *testing.T) { scribe := historyScribe.(*history.MockScribe) - buf := scribe.BufMap[history.RATING_PROFILES_FN] + buf := scribe.GetBuffer(history.RATING_PROFILES_FN) if !strings.Contains(buf.String(), `{"Id":"*out:vdf:0:minu","RatingPlanActivations":[{"ActivationTime":"2012-01-01T00:00:00Z","RatingPlanId":"EVENING","FallbackKeys":null}]}`) { t.Error("Error in destination history content:", buf.String()) } @@ -35,7 +35,7 @@ func TestHistoryRatinPlans(t *testing.T) { func TestHistoryDestinations(t *testing.T) { scribe := historyScribe.(*history.MockScribe) - buf := scribe.BufMap[history.DESTINATIONS_FN] + buf := scribe.GetBuffer(history.DESTINATIONS_FN) expected := `[{"Id":"ALL","Prefixes":["49","41","43"]}, {"Id":"DST_UK_Mobile_BIG5","Prefixes":["447956"]}, {"Id":"GERMANY","Prefixes":["49"]}, diff --git a/history/mock_scribe.go b/history/mock_scribe.go index 808298a8e..df110e4a4 100644 --- a/history/mock_scribe.go +++ b/history/mock_scribe.go @@ -38,8 +38,10 @@ func NewMockScribe() (*MockScribe, error) { } func (s *MockScribe) Record(rec Record, out *int) error { + s.mu.Lock() fn := rec.Filename recordsMap[fn] = recordsMap[fn].SetOrAdd(&rec) + s.mu.Unlock() s.save(fn) return nil } @@ -56,3 +58,9 @@ func (s *MockScribe) save(filename string) error { } return nil } + +func (s *MockScribe) GetBuffer(fn string) *bytes.Buffer { + s.mu.Lock() + defer s.mu.Unlock() + return s.BufMap[fn] +}