From 66a1b1f39a1e1d5499b548b36d18c8daa872d7da Mon Sep 17 00:00:00 2001 From: tjpcc Date: Sat, 28 Jan 2023 14:52:35 -0700 Subject: gopher support. Some of the contrib packages were originally built gemini-specific and had to be refactored into generic core functionality and thin protocol-specific wrappers for each of gemini and gopher. --- gopher/request_test.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 gopher/request_test.go (limited to 'gopher/request_test.go') diff --git a/gopher/request_test.go b/gopher/request_test.go new file mode 100644 index 0000000..1ab7801 --- /dev/null +++ b/gopher/request_test.go @@ -0,0 +1,43 @@ +package gopher_test + +import ( + "bytes" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "tildegit.org/tjp/gus/gopher" +) + +func TestParseRequest(t *testing.T) { + tests := []struct { + requestLine string + path string + query string + }{ + { + requestLine: "\r\n", + path: "/", + }, + { + requestLine: "foo/bar\r\n", + path: "/foo/bar", + }, + { + requestLine: "search\tthis AND that\r\n", + path: "/search", + query: "this+AND+that", + }, + } + + for _, test := range tests { + t.Run(test.requestLine, func(t *testing.T) { + request, err := gopher.ParseRequest(bytes.NewBufferString(test.requestLine)) + require.Nil(t, err) + + assert.Equal(t, test.path, request.Path) + assert.Equal(t, test.query, request.RawQuery) + }) + } +} -- cgit v1.2.3