file_name_util_test.go 484 B

123456789101112131415161718192021
  1. package util
  2. import (
  3. "strconv"
  4. "testing"
  5. "time"
  6. )
  7. // TestFileNameUtil
  8. func TestFileNameUtil(t *testing.T) {
  9. const days = 10
  10. beforeTomorrow, _ := time.ParseDuration("-" + strconv.Itoa((days+1)*24) + "h")
  11. fileNames := []string{
  12. "a2020-10-10-11-12b.sql",
  13. "测试2021-10-10-11-12测试.sql",
  14. time.Now().Add(beforeTomorrow).Format(FileNameFormatStr) + ".sql",
  15. }
  16. if len(fileNames) != len(FileNameBeforeDays(10, fileNames)) {
  17. t.Error("TestFileNameUtil Test failed!")
  18. }
  19. }