Kirika/audio/format/opus/opus_test.go
DataHoarder bd069cdf05
Some checks failed
continuous-integration/drone/push Build is failing
General code inspection cleanup
2022-10-03 11:34:56 +02:00

46 lines
766 B
Go

//go:build !disable_format_opus && cgo
package opus
import (
"git.gammaspectra.live/S.O.N.G/Kirika/audio/format/flac"
"git.gammaspectra.live/S.O.N.G/Kirika/test"
"os"
"testing"
)
func TestEncodeOpus(t *testing.T) {
fp, err := os.Open(test.SingleSample24)
if err != nil {
t.Error(err)
return
}
defer fp.Close()
source, err := flac.NewFormat().Open(fp)
if err != nil {
t.Error(err)
return
}
target, err := os.CreateTemp("/tmp", "encode_test_*.opus")
if err != nil {
t.Error(err)
return
}
defer func() {
name := target.Name()
target.Close()
os.Remove(name)
}()
options := make(map[string]interface{})
options["bitrate"] = "256k"
err = NewFormat().Encode(source, target, options)
if err != nil {
t.Error(err)
return
}
}