sub_helper_test.go 981 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package sub_helper
  2. import (
  3. "github.com/allanpk716/ChineseSubFinder/internal/pkg/my_util"
  4. "path/filepath"
  5. "testing"
  6. )
  7. func TestDeleteOneSeasonSubCacheFolder(t *testing.T) {
  8. testDataPath := "../../../TestData/sub_helper"
  9. testRootDir, err := my_util.CopyTestData(testDataPath)
  10. if err != nil {
  11. t.Fatal(err)
  12. }
  13. err = DeleteOneSeasonSubCacheFolder(testRootDir)
  14. if err != nil {
  15. t.Fatal(err)
  16. }
  17. if my_util.IsDir(filepath.Join(testRootDir, "Sub_S1E0")) == true {
  18. t.Fatal("Sub_S1E0 not delete")
  19. }
  20. }
  21. func TestSearchMatchedSubFileByOneVideo(t *testing.T) {
  22. testDataPath := "../../../TestData/sub_helper"
  23. testRootDir, err := my_util.CopyTestData(testDataPath)
  24. if err != nil {
  25. t.Fatal(err)
  26. }
  27. videoFPath := filepath.Join(testRootDir, "R&M-S05E10", "Rick and Morty - S05E10 - Rickmurai Jack WEBRip-1080p.mp4")
  28. subFiles, err := SearchMatchedSubFileByOneVideo(videoFPath)
  29. if err != nil {
  30. t.Fatal(err)
  31. }
  32. if len(subFiles) != 5 {
  33. t.Fatal("subFiles len != 5")
  34. }
  35. }