Browse Source

修复单元测试问题

Signed-off-by: 716 <[email protected]>
716 3 years ago
parent
commit
9b9ad7ed42

+ 3 - 3
internal/pkg/ffmpeg_helper/ffmpeg_helper_test.go

@@ -13,7 +13,7 @@ func TestGetFFMPEGInfo(t *testing.T) {
 	// TODO: make a video with ffmpeg on each test
 	// TODO: make a video with ffmpeg on each test
 	// https://gist.github.com/SeunghoonBaek/f35e0fd3db80bf55c2707cae5d0f7184
 	// https://gist.github.com/SeunghoonBaek/f35e0fd3db80bf55c2707cae5d0f7184
 	// http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerEscapes.mp4
 	// http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerEscapes.mp4
-	videoFile := unit_test_helper.GetTestDataResourceRootPath([]string{"ffmpeg"}, 4, false)
+	videoFile := unit_test_helper.GetTestDataResourceRootPath([]string{"ffmpeg", "org"}, 4, false)
 	videoFile = filepath.Join(videoFile, "sampleVideo.mp4")
 	videoFile = filepath.Join(videoFile, "sampleVideo.mp4")
 	f := NewFFMPEGHelper()
 	f := NewFFMPEGHelper()
 	bok, ffmpegInfo, err := f.GetFFMPEGInfo(videoFile, Audio)
 	bok, ffmpegInfo, err := f.GetFFMPEGInfo(videoFile, Audio)
@@ -39,7 +39,7 @@ func readString(filePath string) string {
 
 
 func TestParseJsonString2GetFFMPEGInfo(t *testing.T) {
 func TestParseJsonString2GetFFMPEGInfo(t *testing.T) {
 
 
-	testDataPath := unit_test_helper.GetTestDataResourceRootPath([]string{"ffmpeg"}, 4, false)
+	testDataPath := unit_test_helper.GetTestDataResourceRootPath([]string{"ffmpeg", "org"}, 4, false)
 	type args struct {
 	type args struct {
 		videoFileFullPath string
 		videoFileFullPath string
 		input             string
 		input             string
@@ -103,7 +103,7 @@ func TestExportAudioArgsByTimeRange(t *testing.T) {
 
 
 func TestGetAudioInfo(t *testing.T) {
 func TestGetAudioInfo(t *testing.T) {
 
 
-	testDataPath := unit_test_helper.GetTestDataResourceRootPath([]string{"ffmpeg"}, 4, false)
+	testDataPath := unit_test_helper.GetTestDataResourceRootPath([]string{"ffmpeg", "org"}, 4, false)
 	audioFullPath := filepath.Join(testDataPath, "sampleAudio.wav")
 	audioFullPath := filepath.Join(testDataPath, "sampleAudio.wav")
 
 
 	f := NewFFMPEGHelper()
 	f := NewFFMPEGHelper()

+ 10 - 6
internal/pkg/sub_timeline_fixer/pipeline_test.go

@@ -117,6 +117,10 @@ func TestPipeline_FitGSS(t *testing.T) {
 }
 }
 
 
 func TestPipeline_FitGSSByAudio(t *testing.T) {
 func TestPipeline_FitGSSByAudio(t *testing.T) {
+
+	dirRoot := unit_test_helper.GetTestDataResourceRootPath([]string{"sub_timeline_fixer"}, 4, true)
+	dirRoot = filepath.Join(dirRoot, "mix")
+
 	subParserHub := sub_parser_hub.NewSubParserHub(ass.NewParser(), srt.NewParser())
 	subParserHub := sub_parser_hub.NewSubParserHub(ass.NewParser(), srt.NewParser())
 
 
 	type args struct {
 	type args struct {
@@ -136,20 +140,20 @@ func TestPipeline_FitGSSByAudio(t *testing.T) {
 		{name: "Rick and Morty - S05E01 -- 0",
 		{name: "Rick and Morty - S05E01 -- 0",
 			args: args{
 			args: args{
 				audioInfo: vad.AudioInfo{
 				audioInfo: vad.AudioInfo{
-					FileFullPath: "C:\\Tmp\\fixsubtimeline\\Rick and Morty - S05E01\\未知语言_1.pcm",
+					FileFullPath: filepath.Join(dirRoot, "Rick and Morty - S05E01", "未知语言_1.pcm"),
 				},
 				},
-				subFilePath:     "C:\\Tmp\\fixsubtimeline\\Rick and Morty - S05E01\\英_2.ass",
-				srcFixedSubFile: "C:\\Tmp\\fixsubtimeline\\Rick and Morty - S05E01\\org-fix.ass"},
+				subFilePath:     filepath.Join(dirRoot, "Rick and Morty - S05E01", "英_2.ass"),
+				srcFixedSubFile: filepath.Join(dirRoot, "Rick and Morty - S05E01", "org-fix.ass")},
 			want: true, want1: 0.33,
 			want: true, want1: 0.33,
 		},
 		},
 		// Rick and Morty - S05E01
 		// Rick and Morty - S05E01
 		{name: "Rick and Morty - S05E01 -- 1",
 		{name: "Rick and Morty - S05E01 -- 1",
 			args: args{
 			args: args{
 				audioInfo: vad.AudioInfo{
 				audioInfo: vad.AudioInfo{
-					FileFullPath: "C:\\Tmp\\fixsubtimeline\\Rick and Morty - S05E01\\未知语言_1.pcm",
+					FileFullPath: filepath.Join(dirRoot, "Rick and Morty - S05E01", "未知语言_1.pcm"),
 				},
 				},
-				subFilePath:     "C:\\Tmp\\fixsubtimeline\\Rick and Morty - S05E01\\org.ass",
-				srcFixedSubFile: "C:\\Tmp\\fixsubtimeline\\Rick and Morty - S05E01\\org-fix.ass"},
+				subFilePath:     filepath.Join(dirRoot, "Rick and Morty - S05E01", "org.ass"),
+				srcFixedSubFile: filepath.Join(dirRoot, "Rick and Morty - S05E01", "org-fix.ass")},
 			want: true, want1: -6.1,
 			want: true, want1: -6.1,
 		},
 		},
 	}
 	}