Beispiel #1
0
func TestOutput(t *testing.T) {
	filename := "test.mp4"
	param := ff.NewParam("foo", "bar")
	set := ff.NewParamSet(param)
	var output ff.File = ff.NewOutput(filename, set)
	Convey("ff.NewOutput(string, *ff.ParamSet)", t, func() {
		Convey("should not return nil", func() {
			So(output, ShouldNotBeNil)
		})
	})
	Convey("ff.File.Slice() should return paramters in correct order", t, func() {
		expected := []string{"-foo", "bar", filename, "-y"}
		So(output.Slice(), ShouldResemble, expected)
	})
}
Beispiel #2
0
func TestCommand(t *testing.T) {
	filename := "test.mp4"
	param := ff.NewParam("foo", "bar")
	set := ff.NewParamSet(param)
	var input ff.File = ff.NewInput(filename, set)
	var output ff.File = ff.NewOutput(filename, set)
	path := "ffmpeg"

	Convey("ff.NewCommand()", t, func() {
		Convey("Cannot call with empty command (input only)", func() {
			cmd, err := ff.NewCommand("", input)
			So(cmd, ShouldBeNil)
			So(err, ShouldNotBeNil)
		})
		Convey("Cannot call with empty command (input+output)", func() {
			cmd, err := ff.NewCommand("", input, output)
			So(cmd, ShouldBeNil)
			So(err, ShouldNotBeNil)
		})
		Convey("Can call with only input", func() {
			cmd, err := ff.NewCommand(path, input)
			So(cmd, ShouldNotBeNil)
			So(err, ShouldBeNil)
		})
		Convey("Returns error with no input", func() {
			cmd, err := ff.NewCommand(path, nil, output)
			So(cmd, ShouldBeNil)
			So(err, ShouldNotBeNil)
			cmd, err = ff.NewCommand(path, nil)
			So(cmd, ShouldBeNil)
			So(err, ShouldNotBeNil)
		})
		Convey("Returns error no input or output", func() {
			cmd, err := ff.NewCommand(path, nil)
			So(cmd, ShouldBeNil)
			So(err, ShouldNotBeNil)
		})
	})
	Convey("ff.Command.Slice() input+output", t, func() {
		cmd, _ := ff.NewCommand(path, input, output)
		slice := cmd.Slice()
		Convey("Should not return nil", func() {
			So(slice, ShouldNotBeNil)
		})
		Convey("Should return a []string slice", func() {
			So(slice, ShouldHaveSameTypeAs, []string{})
		})
		Convey("Should resemble expected value", func() {
			expected := []string{
				"-foo", "bar", "-i", filename,
				"-foo", "bar", filename, "-y",
			}
			So(slice, ShouldResemble, expected)
		})
	})
	Convey("ff.Command.Slice() input only", t, func() {
		cmd, _ := ff.NewCommand(path, input)
		slice := cmd.Slice()
		Convey("Should not return nil", func() {
			So(slice, ShouldNotBeNil)
		})
		Convey("Should return a []string slice", func() {
			So(slice, ShouldHaveSameTypeAs, []string{})
		})
		Convey("Should resemble expected value", func() {
			expected := []string{
				"-foo", "bar", "-i", filename,
			}
			So(slice, ShouldResemble, expected)
		})
	})
}