From e13c99bda613ef607c14fd305b7ae73d5678f2af Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Fri, 2 Mar 2012 20:58:37 +0200 Subject: [PATCH] moved test data to separate folder --- {timespans => data}/test.kch | Bin .../test_activation_periods.json | 0 {timespans => data}/test_destinations.json | 0 {timespans => data}/test_tariffplans.json | 0 {timespans => data}/test_userbudgets.json | 0 timespans/activationperiod_test.go | 2 +- timespans/calldesc_test.go | 16 ++++---- timespans/destinations_test.go | 18 ++++----- timespans/tariff_plans_test.go | 38 +++++++++--------- timespans/timespans_test.go | 2 +- timespans/userbudget_test.go | 6 +-- 11 files changed, 40 insertions(+), 42 deletions(-) rename {timespans => data}/test.kch (100%) rename {timespans => data}/test_activation_periods.json (100%) rename {timespans => data}/test_destinations.json (100%) rename {timespans => data}/test_tariffplans.json (100%) rename {timespans => data}/test_userbudgets.json (100%) diff --git a/timespans/test.kch b/data/test.kch similarity index 100% rename from timespans/test.kch rename to data/test.kch diff --git a/timespans/test_activation_periods.json b/data/test_activation_periods.json similarity index 100% rename from timespans/test_activation_periods.json rename to data/test_activation_periods.json diff --git a/timespans/test_destinations.json b/data/test_destinations.json similarity index 100% rename from timespans/test_destinations.json rename to data/test_destinations.json diff --git a/timespans/test_tariffplans.json b/data/test_tariffplans.json similarity index 100% rename from timespans/test_tariffplans.json rename to data/test_tariffplans.json diff --git a/timespans/test_userbudgets.json b/data/test_userbudgets.json similarity index 100% rename from timespans/test_userbudgets.json rename to data/test_userbudgets.json diff --git a/timespans/activationperiod_test.go b/timespans/activationperiod_test.go index 24cc2947a..bc9701cf4 100644 --- a/timespans/activationperiod_test.go +++ b/timespans/activationperiod_test.go @@ -25,7 +25,7 @@ import ( ) func TestApRestoreKyoto(t *testing.T) { - getter, _ := NewKyotoStorage("test.kch") + getter, _ := NewKyotoStorage("../data/test.kch") defer getter.Close() cd := &CallDescriptor{CstmId: "vdf", Subject: "rif", DestinationPrefix: "0257", storageGetter: getter} diff --git a/timespans/calldesc_test.go b/timespans/calldesc_test.go index be3db32e7..64557d391 100644 --- a/timespans/calldesc_test.go +++ b/timespans/calldesc_test.go @@ -36,7 +36,7 @@ BenchmarkMongoGetCost 10000 323262 ns/op */ func TestKyotoSplitSpans(t *testing.T) { - getter, _ := NewKyotoStorage("test.kch") + getter, _ := NewKyotoStorage("../data/test.kch") defer getter.Close() t1 := time.Date(2012, time.February, 2, 17, 30, 0, 0, time.UTC) @@ -68,7 +68,7 @@ func TestRedisSplitSpans(t *testing.T) { } func TestKyotoGetCost(t *testing.T) { - getter, _ := NewKyotoStorage("test.kch") + getter, _ := NewKyotoStorage("../data/test.kch") defer getter.Close() t1 := time.Date(2012, time.February, 2, 17, 30, 0, 0, time.UTC) @@ -307,7 +307,7 @@ func BenchmarkRedisGetCost(b *testing.B) { func BenchmarkKyotoGetting(b *testing.B) { b.StopTimer() - getter, _ := NewKyotoStorage("test.kch") + getter, _ := NewKyotoStorage("../data/test.kch") defer getter.Close() t1 := time.Date(2012, time.February, 2, 17, 30, 0, 0, time.UTC) @@ -322,7 +322,7 @@ func BenchmarkKyotoGetting(b *testing.B) { func BenchmarkKyotoRestoring(b *testing.B) { b.StopTimer() - getter, _ := NewKyotoStorage("test.kch") + getter, _ := NewKyotoStorage("../data/test.kch") defer getter.Close() t1 := time.Date(2012, time.February, 2, 17, 30, 0, 0, time.UTC) @@ -336,7 +336,7 @@ func BenchmarkKyotoRestoring(b *testing.B) { func BenchmarkSplitting(b *testing.B) { b.StopTimer() - getter, _ := NewKyotoStorage("test.kch") + getter, _ := NewKyotoStorage("../data/test.kch") defer getter.Close() t1 := time.Date(2012, time.February, 2, 17, 30, 0, 0, time.UTC) @@ -351,7 +351,7 @@ func BenchmarkSplitting(b *testing.B) { func BenchmarkKyotoGetCost(b *testing.B) { b.StopTimer() - getter, _ := NewKyotoStorage("test.kch") + getter, _ := NewKyotoStorage("../data/test.kch") defer getter.Close() t1 := time.Date(2012, time.February, 2, 17, 30, 0, 0, time.UTC) @@ -393,7 +393,7 @@ func BenchmarkMongoGetCost(b *testing.B) { func BenchmarkKyotoSingleGetSessionTime(b *testing.B) { b.StopTimer() - getter, _ := NewKyotoStorage("test.kch") + getter, _ := NewKyotoStorage("../data/test.kch") defer getter.Close() cd := &CallDescriptor{CstmId: "vdf", Subject: "minutosu", DestinationPrefix: "0723", storageGetter: getter, Amount: 100} b.StartTimer() @@ -404,7 +404,7 @@ func BenchmarkKyotoSingleGetSessionTime(b *testing.B) { func BenchmarkKyotoMultipleGetSessionTime(b *testing.B) { b.StopTimer() - getter, _ := NewKyotoStorage("test.kch") + getter, _ := NewKyotoStorage("../data/test.kch") defer getter.Close() cd := &CallDescriptor{CstmId: "vdf", Subject: "minutosu", DestinationPrefix: "0723", storageGetter: getter, Amount: 5400} b.StartTimer() diff --git a/timespans/destinations_test.go b/timespans/destinations_test.go index 113355053..037ee1196 100644 --- a/timespans/destinations_test.go +++ b/timespans/destinations_test.go @@ -23,17 +23,17 @@ import ( ) func TestDestinationStoreRestore(t *testing.T) { - nationale = &Destination{Id: "nat", Prefixes: []string{"0257", "0256", "0723"}} - s := nationale.store() - d1 := &Destination{Id: "nat"} - d1.restore(s) - if d1.store() != s { - t.Errorf("Expected %q was %q", s, d1.store()) - } + nationale = &Destination{Id: "nat", Prefixes: []string{"0257", "0256", "0723"}} + s := nationale.store() + d1 := &Destination{Id: "nat"} + d1.restore(s) + if d1.store() != s { + t.Errorf("Expected %q was %q", s, d1.store()) + } } func TestDestinationKyotoStore(t *testing.T) { - getter, _ := NewKyotoStorage("test.kch") + getter, _ := NewKyotoStorage("../data/test.kch") defer getter.Close() nationale = &Destination{Id: "nat", Prefixes: []string{"0257", "0256", "0723"}} getter.SetDestination(nationale) @@ -85,7 +85,7 @@ func TestDestinationContainsPrefix(t *testing.T) { /********************************* Benchmarks **********************************/ func BenchmarkDestinationKyotoStoreRestore(b *testing.B) { - getter, _ := NewKyotoStorage("test.kch") + getter, _ := NewKyotoStorage("../data/test.kch") defer getter.Close() nationale = &Destination{Id: "nat", Prefixes: []string{"0257", "0256", "0723"}} for i := 0; i < b.N; i++ { diff --git a/timespans/tariff_plans_test.go b/timespans/tariff_plans_test.go index 52ee2dc9f..ff1e9cb42 100644 --- a/timespans/tariff_plans_test.go +++ b/timespans/tariff_plans_test.go @@ -24,28 +24,26 @@ import ( ) func TestTariffPlanStoreRestore(t *testing.T) { - b1 := &MinuteBucket{Seconds: 10, Priority: 10, Price: 0.01, DestinationId: "nationale"} - b2 := &MinuteBucket{Seconds: 100, Priority: 20, Price: 0.0, DestinationId: "retea"} - rcb := &RecivedCallBonus{Credit: 100} - vd := &VolumeDiscount{100, 10} - seara := &TariffPlan{Id: "seara_voo", - SmsCredit: 100, - ReceivedCallSecondsLimit: 0, - RecivedCallBonus: rcb, - MinuteBuckets: []*MinuteBucket{b1, b2}, - VolumeDiscountThresholds: []*VolumeDiscount{vd}} - s := seara.store() - tp1 := &TariffPlan{Id: "seara_voo"} - tp1.restore(s) - if tp1.store() != s { - t.Errorf("Expected %q was %q", s, tp1.store()) - } + b1 := &MinuteBucket{Seconds: 10, Priority: 10, Price: 0.01, DestinationId: "nationale"} + b2 := &MinuteBucket{Seconds: 100, Priority: 20, Price: 0.0, DestinationId: "retea"} + rcb := &RecivedCallBonus{Credit: 100} + vd := &VolumeDiscount{100, 10} + seara := &TariffPlan{Id: "seara_voo", + SmsCredit: 100, + ReceivedCallSecondsLimit: 0, + RecivedCallBonus: rcb, + MinuteBuckets: []*MinuteBucket{b1, b2}, + VolumeDiscountThresholds: []*VolumeDiscount{vd}} + s := seara.store() + tp1 := &TariffPlan{Id: "seara_voo"} + tp1.restore(s) + if tp1.store() != s { + t.Errorf("Expected %q was %q", s, tp1.store()) + } } - - func TestTariffPlanKyotoStore(t *testing.T) { - getter, _ := NewKyotoStorage("test.kch") + getter, _ := NewKyotoStorage("../data/test.kch") defer getter.Close() b1 := &MinuteBucket{Seconds: 10, Priority: 10, Price: 0.01, DestinationId: "nationale"} b2 := &MinuteBucket{Seconds: 100, Priority: 20, Price: 0.0, DestinationId: "retea"} @@ -94,7 +92,7 @@ func TestTariffPlanMongoStore(t *testing.T) { /********************************* Benchmarks **********************************/ func BenchmarkTariffPlanKyotoStoreRestore(b *testing.B) { - getter, _ := NewKyotoStorage("test.kch") + getter, _ := NewKyotoStorage("../data/test.kch") defer getter.Close() b1 := &MinuteBucket{Seconds: 10, Priority: 10, Price: 0.01, DestinationId: "nationale"} b2 := &MinuteBucket{Seconds: 100, Priority: 20, Price: 0.0, DestinationId: "retea"} diff --git a/timespans/timespans_test.go b/timespans/timespans_test.go index c0ee69160..0164498ab 100644 --- a/timespans/timespans_test.go +++ b/timespans/timespans_test.go @@ -184,7 +184,7 @@ func TestSplitByActivationTime(t *testing.T) { } func TestTimespanGetCost(t *testing.T) { - getter, _ := NewKyotoStorage("test.kch") + getter, _ := NewKyotoStorage("../data/test.kch") defer getter.Close() t1 := time.Date(2012, time.February, 5, 17, 45, 0, 0, time.UTC) t2 := time.Date(2012, time.February, 5, 17, 55, 0, 0, time.UTC) diff --git a/timespans/userbudget_test.go b/timespans/userbudget_test.go index b64540757..cbddea242 100644 --- a/timespans/userbudget_test.go +++ b/timespans/userbudget_test.go @@ -68,7 +68,7 @@ func TestGetPricedSeconds(t *testing.T) { } func TestUserBudgetKyotoStore(t *testing.T) { - getter, _ := NewKyotoStorage("test.kch") + getter, _ := NewKyotoStorage("../data/test.kch") defer getter.Close() b1 := &MinuteBucket{Seconds: 10, Priority: 10, Price: 0.01, DestinationId: "nationale"} b2 := &MinuteBucket{Seconds: 100, Priority: 20, Price: 0.0, DestinationId: "retea"} @@ -377,7 +377,7 @@ func TestGetVolumeDiscountSteps(t *testing.T) { } func TestRecivedCallsBonus(t *testing.T) { - getter, _ := NewKyotoStorage("test.kch") + getter, _ := NewKyotoStorage("../data/test.kch") defer getter.Close() rcb := &RecivedCallBonus{Credit: 100} seara := &TariffPlan{Id: "seara_voo", SmsCredit: 100, ReceivedCallSecondsLimit: 10, RecivedCallBonus: rcb} @@ -404,7 +404,7 @@ func BenchmarkGetSecondForPrefix(b *testing.B) { } func BenchmarkUserBudgetKyotoStoreRestore(b *testing.B) { - getter, _ := NewKyotoStorage("test.kch") + getter, _ := NewKyotoStorage("../data/test.kch") defer getter.Close() b1 := &MinuteBucket{Seconds: 10, Priority: 10, Price: 0.01, DestinationId: "nationale"} b2 := &MinuteBucket{Seconds: 100, Priority: 20, Price: 0.0, DestinationId: "retea"}