hot_fix_hub_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package hot_fix
  2. import (
  3. "path/filepath"
  4. "testing"
  5. "github.com/ChineseSubFinder/ChineseSubFinder/pkg/types"
  6. "github.com/ChineseSubFinder/ChineseSubFinder/internal/dao"
  7. "github.com/ChineseSubFinder/ChineseSubFinder/internal/models"
  8. "github.com/ChineseSubFinder/ChineseSubFinder/pkg/log_helper"
  9. "github.com/ChineseSubFinder/ChineseSubFinder/pkg/unit_test_helper"
  10. )
  11. func TestHotFixProcess(t *testing.T) {
  12. // 先删除 db
  13. err := dao.DeleteDbFile()
  14. if err != nil {
  15. t.Fatal(err)
  16. }
  17. testDataPath := unit_test_helper.GetTestDataResourceRootPath([]string{"hotfix", "001"}, 4, true)
  18. movieDir := "movies"
  19. seriesDir := "series"
  20. // 测试文件夹
  21. testMovieDir := filepath.Join(testDataPath, movieDir)
  22. testSeriesDir := filepath.Join(testDataPath, seriesDir)
  23. // 开始修复
  24. err = HotFixProcess(log_helper.GetLogger4Tester(), types.HotFixParam{
  25. MovieRootDirs: []string{testMovieDir},
  26. SeriesRootDirs: []string{testSeriesDir},
  27. })
  28. if err != nil {
  29. t.Fatal(err)
  30. }
  31. // 判断数据库的标记是否正确
  32. hotfixResult := models.HotFix{}
  33. result := dao.GetDb().Where("key = ?", "001").First(&hotfixResult)
  34. if result.Error != nil {
  35. t.Fatal(result.Error)
  36. }
  37. }