This commit is contained in:
DanB
2014-11-27 19:35:39 +01:00
2 changed files with 10 additions and 2 deletions

View File

@@ -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"]},

View File

@@ -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]
}