better test reveal mongo servialization problem

This commit is contained in:
Radu Ioan Fericean
2012-03-01 21:34:42 +02:00
parent 9e3b9ef191
commit dd5018c99d
4 changed files with 23 additions and 17 deletions

View File

@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package timespans
import (
"reflect"
"testing"
)
@@ -27,7 +28,7 @@ func TestDestinationKyotoStore(t *testing.T) {
nationale = &Destination{Id: "nat", Prefixes: []string{"0257", "0256", "0723"}}
getter.SetDestination(nationale)
result, _ := getter.GetDestination(nationale.Id)
if result.Id != nationale.Id || result.Prefixes[2] != nationale.Prefixes[2] {
if !reflect.DeepEqual(nationale, result) {
t.Errorf("Expected %q was %q", nationale, result)
}
}
@@ -41,7 +42,7 @@ func TestDestinationRedisStore(t *testing.T) {
nationale = &Destination{Id: "nat", Prefixes: []string{"0257", "0256", "0723"}}
getter.SetDestination(nationale)
result, _ := getter.GetDestination(nationale.Id)
if result.Id != nationale.Id || result.Prefixes[2] != nationale.Prefixes[2] {
if !reflect.DeepEqual(nationale, result) {
t.Errorf("Expected %q was %q", nationale, result)
}
}
@@ -55,7 +56,7 @@ func TestDestinationMongoStore(t *testing.T) {
nationale = &Destination{Id: "nat", Prefixes: []string{"0257", "0256", "0723"}}
getter.SetDestination(nationale)
result, _ := getter.GetDestination(nationale.Id)
if result.Id != nationale.Id || result.Prefixes[2] != nationale.Prefixes[2] {
if !reflect.DeepEqual(nationale, result) {
t.Errorf("Expected %q was %q", nationale, result)
}
}

View File

@@ -18,6 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package timespans
import (
// "log"
"reflect"
"testing"
)
@@ -30,7 +32,7 @@ func TestTariffPlanKyotoStore(t *testing.T) {
seara := &TariffPlan{Id: "seara_voo", SmsCredit: 100, ReceivedCallSecondsLimit: 0, MinuteBuckets: []*MinuteBucket{b1, b2}, VolumeDiscountThresholds: []*VolumeDiscount{vd}}
getter.SetTariffPlan(seara)
result, _ := getter.GetTariffPlan(seara.Id)
if result.SmsCredit != seara.SmsCredit || len(result.MinuteBuckets) != len(seara.MinuteBuckets) {
if !reflect.DeepEqual(seara, result) {
t.Errorf("Expected %q was %q", seara, result)
}
}
@@ -44,7 +46,7 @@ func TestTariffPlanRedisStore(t *testing.T) {
seara := &TariffPlan{Id: "seara_voo", SmsCredit: 100, ReceivedCallSecondsLimit: 0, MinuteBuckets: []*MinuteBucket{b1, b2}, VolumeDiscountThresholds: []*VolumeDiscount{vd}}
getter.SetTariffPlan(seara)
result, _ := getter.GetTariffPlan(seara.Id)
if result.SmsCredit != seara.SmsCredit || len(result.MinuteBuckets) != len(seara.MinuteBuckets) {
if !reflect.DeepEqual(seara, result) {
t.Errorf("Expected %q was %q", seara, result)
}
}
@@ -54,10 +56,13 @@ func TestTariffPlanMongoStore(t *testing.T) {
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"}
seara := &TariffPlan{Id: "seara_voo", SmsCredit: 100, MinuteBuckets: []*MinuteBucket{b1, b2}}
vd := &VolumeDiscount{100, 10}
seara := &TariffPlan{Id: "seara_voo", SmsCredit: 100, ReceivedCallSecondsLimit: 0, MinuteBuckets: []*MinuteBucket{b1, b2}, VolumeDiscountThresholds: []*VolumeDiscount{vd}}
getter.SetTariffPlan(seara)
result, _ := getter.GetTariffPlan(seara.Id)
if result.SmsCredit != seara.SmsCredit || len(result.MinuteBuckets) != len(seara.MinuteBuckets) {
if !reflect.DeepEqual(seara, result) {
t.Log(seara)
t.Log(result)
t.Errorf("Expected %q was %q", seara, result)
}
}

Binary file not shown.

View File

@@ -18,8 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package timespans
import (
// "log"
"reflect"
"testing"
//"log"
)
var (
@@ -58,11 +59,12 @@ func TestUserBudgetKyotoStore(t *testing.T) {
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"}
seara := &TariffPlan{Id: "seara", SmsCredit: 100, MinuteBuckets: []*MinuteBucket{b1, b2}}
rifsBudget := &UserBudget{Id: "other", MinuteBuckets: []*MinuteBucket{b1, b2}, Credit: 21, tariffPlan: seara, ResetDayOfTheMonth: 10}
rifsBudget := &UserBudget{Id: "other", MinuteBuckets: []*MinuteBucket{b1, b2}, Credit: 21, ResetDayOfTheMonth: 10}
getter.SetUserBudget(rifsBudget)
result, _ := getter.GetUserBudget(rifsBudget.Id)
if result.SmsCredit != rifsBudget.SmsCredit || len(result.MinuteBuckets) != len(rifsBudget.MinuteBuckets) {
if !reflect.DeepEqual(rifsBudget, result) {
t.Log(rifsBudget)
t.Log(result)
t.Errorf("Expected %q was %q", rifsBudget, result)
}
}
@@ -72,11 +74,10 @@ func TestUserBudgetRedisStore(t *testing.T) {
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"}
seara := &TariffPlan{Id: "seara", SmsCredit: 100, MinuteBuckets: []*MinuteBucket{b1, b2}}
rifsBudget := &UserBudget{Id: "other", MinuteBuckets: []*MinuteBucket{b1, b2}, Credit: 21, tariffPlan: seara, ResetDayOfTheMonth: 10}
rifsBudget := &UserBudget{Id: "other", MinuteBuckets: []*MinuteBucket{b1, b2}, Credit: 21, ResetDayOfTheMonth: 10}
getter.SetUserBudget(rifsBudget)
result, _ := getter.GetUserBudget(rifsBudget.Id)
if result.SmsCredit != rifsBudget.SmsCredit || len(result.MinuteBuckets) != len(rifsBudget.MinuteBuckets) {
if !reflect.DeepEqual(rifsBudget, result) {
t.Errorf("Expected %q was %q", rifsBudget, result)
}
}
@@ -89,11 +90,10 @@ func TestUserBudgetMongoStore(t *testing.T) {
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"}
seara := &TariffPlan{Id: "seara", SmsCredit: 100, MinuteBuckets: []*MinuteBucket{b1, b2}}
rifsBudget := &UserBudget{Id: "other", MinuteBuckets: []*MinuteBucket{b1, b2}, Credit: 21, tariffPlan: seara, ResetDayOfTheMonth: 10}
rifsBudget := &UserBudget{Id: "other", MinuteBuckets: []*MinuteBucket{b1, b2}, Credit: 21, ResetDayOfTheMonth: 10}
getter.SetUserBudget(rifsBudget)
result, _ := getter.GetUserBudget(rifsBudget.Id)
if result.SmsCredit != rifsBudget.SmsCredit || len(result.MinuteBuckets) != len(rifsBudget.MinuteBuckets) {
if !reflect.DeepEqual(rifsBudget, result) {
t.Errorf("Expected %q was %q", rifsBudget, result)
}
}