Add basic tests to migrator by timvaillancourt · Pull Request #1168 · github/gh-ost

Description

This PR adds basic tests to a few funcs from go/logic/migrator.go

Also some logic in migrator.printStatus() was moved to smaller funcs for testing, such as:

  • migrator.getProgressPercent(rowsEstimated int64) (progressPct float64)
  • migrator.getMigrationETA(rowsEstimated int64) (eta string, etaDuration time.Duration)
  • migrator.getMigrationStateAndETA(rowsEstimated int64) (state, eta string, etaDuration time.Duration)
  • migrator.shouldPrintStatus(rule PrintStatusRule, elapsedSeconds int64, etaDuration time.Duration) (shouldPrint bool)
  • migrator.shouldPrintMigrationStatus(rule PrintStatusRule, elapsedSeconds int64) (shouldPrint bool)

The logic that moved to funcs should be unchanged

Lastly, the migrator.validateStatement() func was renamed to migrator.validateAlterStatement() for clarity

In case this PR introduced Go code changes:

  • contributed code is using same conventions as original code
  • script/cibuild returns with no formatting errors, build errors or unit test errors.