hot_fix_hub_test.go 1.0 KB

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