convert: compact table test and remove t.Run use

This commit is contained in:
Jonathan Ingram
2017-09-20 17:31:50 +10:00
committed by Hamish
parent 9e7fa8a68e
commit 2228da9d5d
+10 -29
View File
@@ -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)
}
})
} }
} }