hot_fix_hub_test.go 1.0 KB

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