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
|
||||
|
||||
import (
|
||||
"io"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestConvert(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
r io.Reader
|
||||
mimeType string
|
||||
readability bool
|
||||
resp *Response
|
||||
err error
|
||||
}{
|
||||
{
|
||||
name: "trims space",
|
||||
mimeType: "text/plain",
|
||||
r: strings.NewReader(" \n\n\nthe file\n\n"),
|
||||
resp: &Response{
|
||||
Body: "the file",
|
||||
},
|
||||
},
|
||||
func TestConvertTrimsSpace(t *testing.T) {
|
||||
resp, err := Convert(
|
||||
strings.NewReader(" \n\n\nthe \n file\n\n"),
|
||||
"text/plain",
|
||||
false,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("got error = %v, want nil", err)
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
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)
|
||||
}
|
||||
})
|
||||
if want := "the \n file"; resp.Body != want {
|
||||
t.Errorf("body = %v, want %v", resp.Body, want)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user