mirror of
https://github.com/sajari/docconv.git
synced 2026-10-16 21:21:59 +08:00
convert: compact table test and remove t.Run use
This commit is contained in:
+10
-29
@@ -1,39 +1,20 @@
|
|||||||
package docconv
|
package docconv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"reflect"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestConvert(t *testing.T) {
|
func TestConvertTrimsSpace(t *testing.T) {
|
||||||
tests := []struct {
|
resp, err := Convert(
|
||||||
name string
|
strings.NewReader(" \n\n\nthe \n file\n\n"),
|
||||||
r io.Reader
|
"text/plain",
|
||||||
mimeType string
|
false,
|
||||||
readability bool
|
)
|
||||||
resp *Response
|
if err != nil {
|
||||||
err error
|
t.Fatalf("got error = %v, want nil", err)
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "trims space",
|
|
||||||
mimeType: "text/plain",
|
|
||||||
r: strings.NewReader(" \n\n\nthe file\n\n"),
|
|
||||||
resp: &Response{
|
|
||||||
Body: "the file",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
if want := "the \n file"; resp.Body != want {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Errorf("body = %v, want %v", resp.Body, want)
|
||||||
got, err := Convert(tt.r, tt.mimeType, tt.readability)
|
|
||||||
if err != tt.err {
|
|
||||||
t.Fatalf("Convert() error = %v, want %v", err, tt.err)
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(got, tt.resp) {
|
|
||||||
t.Errorf("Convert() = %v, want %v", got, tt.resp)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user