Skip to content

Commit

Permalink
added a test TrimLengthVideo
Browse files Browse the repository at this point in the history
  • Loading branch information
roddy3 committed Apr 9, 2022
1 parent f357d2a commit 043ff76
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions TemplateVideo/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
var ffmpeg string

func init() {
cmd := exec.Command("where", "ffmpeg")
cmd := exec.Command("which", "ffmpeg")
output, err := cmd.CombinedOutput()
checkCMDError(output, err)

Expand Down Expand Up @@ -209,7 +209,7 @@ func Test_cmdGetVideoLength(t *testing.T) {
tests := []struct {
name string
args args
want float64
want *exec.Cmd
}{
{
"get correct video duration",
Expand All @@ -227,8 +227,10 @@ func Test_cmdGetVideoLength(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
//cmd := cmdGetVideoLength(tt.args.inputDirectory)
//check if it is equal of what we want

if got := cmdGetVideoLength(tt.args.inputDirectory); got != tt.want {
t.Errorf("expected video length of sample_video.mp4 to be %f but got %f", tt.want)
t.Errorf("cmdGetVideoLength() = %v, want %v", got, tt.want)

}
//output, err := cmd.CombinedOutput()
//checkCMDError(output, err)
Expand All @@ -241,3 +243,33 @@ func Test_cmdGetVideoLength(t *testing.T) {
})
}
}

func Test_cmdTrimLengthOfVideo(t *testing.T) {
type args struct {
duration string
tempPath string
}
tests := []struct {
name string
args args
want *exec.Cmd
}{
" get correct video duration",
args{duration: "9400",
tempPath: "",
exec.Command("ffmpeg",
"-i", tempPath+"/merged_video.mp4",
"-c", "copy", "-t", duration,
"-y",
tempPath+"/final.mp4"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
fmt.Println(cmdTrimLengthOfVideo(tt.args.duration, tt.args.tempPath).String())
if got := cmdTrimLengthOfVideo(tt.args.duration, tt.args.tempPath).String(); got != tt.want.String() {
t.Errorf("cmdTrimLengthOfVideo() = = %v, want %v", got, tt.want)
}
})
}
}

0 comments on commit 043ff76

Please sign in to comment.