archive_test.go 589 B

123456789101112131415161718192021222324252627282930313233
  1. package service
  2. import (
  3. "testing"
  4. "go-common/app/job/main/up/model/archivemodel"
  5. )
  6. func Test_archiveStateChange(t *testing.T) {
  7. var (
  8. testcase = [][]*archivemodel.ArchiveCanal{
  9. {{State: 0}, {State: -1}},
  10. {{State: -5}, {State: 0}},
  11. {{State: 10}, {State: 10}},
  12. {{State: -5}, {State: -5}},
  13. }
  14. testresult = []bool{
  15. true,
  16. true,
  17. false,
  18. false,
  19. }
  20. )
  21. for i := range testcase {
  22. var cas = testcase[i]
  23. if archiveStateChange(cas[0], cas[1]) != testresult[i] {
  24. t.Errorf("test fail, testcase[%d]=%v, expect=%t", i, cas, testresult[i])
  25. t.Fail()
  26. }
  27. }
  28. }