simCardStatisticsRepo_test.go 707 B

1234567891011121314151617181920212223242526
  1. package mongo
  2. import "testing"
  3. func TestSimCardRunComplete(t *testing.T) {
  4. zero, one := uint64(0), uint64(1)
  5. run := simCardRun{
  6. SmartHubLastPage: &one, AcceleronixLastPage: &one,
  7. SavedPages: []string{"SmartHub:0", "SmartHub:1", "Acceleronix:1"},
  8. }
  9. if !simCardRunComplete(run) {
  10. t.Fatal("all pages saved should complete the run")
  11. }
  12. run.SavedPages = []string{"SmartHub:0", "Acceleronix:1"}
  13. if simCardRunComplete(run) {
  14. t.Fatal("missing page must keep run pending")
  15. }
  16. run.SmartHubLastPage = &zero
  17. if !simCardRunComplete(run) {
  18. t.Fatal("SmartHub page zero is a valid final page")
  19. }
  20. run.Sent = true
  21. if simCardRunComplete(run) {
  22. t.Fatal("sent run must not enqueue another report")
  23. }
  24. }