52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package commands
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/rogeecn/fabfile"
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
)
|
|
|
|
func Test_getVideoSize(t *testing.T) {
|
|
Convey("getVideoSize", t, func() {
|
|
Convey("test getVideoSize", func() {
|
|
file := fabfile.MustFind("fixtures/camera.mp4")
|
|
width, height, err := getVideoSize(file)
|
|
So(err, ShouldBeNil)
|
|
So(width, ShouldEqual, 1924)
|
|
So(height, ShouldEqual, 1080)
|
|
})
|
|
})
|
|
}
|
|
|
|
func Test_compressVideo(t *testing.T) {
|
|
Convey("compressVideo", t, func() {
|
|
Convey("test compressVideo", func() {
|
|
srcFile := fabfile.MustFind("fixtures/camera.mp4")
|
|
dstFile := filepath.Join(os.TempDir(), "camera.mp4")
|
|
t.Log("dstFile", dstFile)
|
|
|
|
err := compressVideo(srcFile, dstFile)
|
|
So(err, ShouldBeNil)
|
|
})
|
|
})
|
|
}
|
|
|
|
func Test_runCommand(t *testing.T) {
|
|
Convey("runCommand", t, func() {
|
|
Convey("test ffprobe", func() {
|
|
file := "/mnt/yangpingliang/publish/原唱《义烈女》庄兄你一席话义重情长(杨红霞).mp4"
|
|
if _, err := os.Stat(file); os.IsNotExist(err) {
|
|
t.Fatalf("File does not exist: %s", file)
|
|
}
|
|
|
|
width, height, err := getVideoSize(file)
|
|
So(err, ShouldBeNil)
|
|
So(width, ShouldNotBeZeroValue)
|
|
So(height, ShouldNotBeZeroValue)
|
|
})
|
|
})
|
|
}
|