Loading extract/extract_test.go +25 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ import ( "net/http" "net/url" "testing" "github.com/taironas/tinygraphs/format" ) func TestSize(t *testing.T) { Loading @@ -29,3 +31,26 @@ func TestSize(t *testing.T) { } } } func TestFormat(t *testing.T) { tests := []struct { title string url string fmt format.Format }{ {"test wrong input", "http://www.tg.c?fmt=foo", format.JPEG}, {"test no input", "http://www.tg.c", format.JPEG}, {"test good input jpeg", "http://www.tg.c?fmt=jpeg", format.JPEG}, {"test good input svg", "http://www.tg.c?fmt=svg", format.SVG}, } for _, test := range tests { t.Log(test.title) r := &http.Request{Method: "GET"} r.URL, _ = url.Parse(test.url) f := Format(r) if f != test.fmt { t.Errorf("expected %d got %d", test.fmt, f) } } } Loading
extract/extract_test.go +25 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ import ( "net/http" "net/url" "testing" "github.com/taironas/tinygraphs/format" ) func TestSize(t *testing.T) { Loading @@ -29,3 +31,26 @@ func TestSize(t *testing.T) { } } } func TestFormat(t *testing.T) { tests := []struct { title string url string fmt format.Format }{ {"test wrong input", "http://www.tg.c?fmt=foo", format.JPEG}, {"test no input", "http://www.tg.c", format.JPEG}, {"test good input jpeg", "http://www.tg.c?fmt=jpeg", format.JPEG}, {"test good input svg", "http://www.tg.c?fmt=svg", format.SVG}, } for _, test := range tests { t.Log(test.title) r := &http.Request{Method: "GET"} r.URL, _ = url.Parse(test.url) f := Format(r) if f != test.fmt { t.Errorf("expected %d got %d", test.fmt, f) } } }