fix: qmc test
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Unlock Music Dev 2022-12-04 23:14:06 +08:00
parent ea3236e14b
commit d2019b04ec
Signed by: um-dev
GPG Key ID: 95202E10D3413A1D

View File

@ -7,6 +7,8 @@ import (
"os" "os"
"reflect" "reflect"
"testing" "testing"
"unlock-music.dev/cli/algo/common"
) )
func loadTestDataQmcDecoder(filename string) ([]byte, []byte, error) { func loadTestDataQmcDecoder(filename string) ([]byte, []byte, error) {
@ -29,13 +31,14 @@ func loadTestDataQmcDecoder(filename string) ([]byte, []byte, error) {
func TestMflac0Decoder_Read(t *testing.T) { func TestMflac0Decoder_Read(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
fileExt string
wantErr bool wantErr bool
}{ }{
{"mflac0_rc4", false}, {"mflac0_rc4", ".mflac0", false},
{"mflac_rc4", false}, {"mflac_rc4", ".mflac", false},
{"mflac_map", false}, {"mflac_map", ".mflac", false},
{"mgg_map", false}, {"mgg_map", ".mgg", false},
{"qmc0_static", false}, {"qmc0_static", ".qmc0", false},
} }
for _, tt := range tests { for _, tt := range tests {
@ -45,7 +48,10 @@ func TestMflac0Decoder_Read(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
d := NewDecoder(bytes.NewReader(raw)) d := NewDecoder(&common.DecoderParams{
Reader: bytes.NewReader(raw),
Extension: tt.fileExt,
})
if err := d.Validate(); err != nil { if err := d.Validate(); err != nil {
t.Errorf("validate file error = %v", err) t.Errorf("validate file error = %v", err)
} }
@ -81,7 +87,10 @@ func TestMflac0Decoder_Validate(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
d := NewDecoder(bytes.NewReader(raw)) d := NewDecoder(&common.DecoderParams{
Reader: bytes.NewReader(raw),
Extension: tt.fileExt,
})
if err := d.Validate(); err != nil { if err := d.Validate(); err != nil {
t.Errorf("read bytes from decoder error = %v", err) t.Errorf("read bytes from decoder error = %v", err)