summaryrefslogtreecommitdiff
path: root/gemini/response_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'gemini/response_test.go')
-rw-r--r--gemini/response_test.go23
1 files changed, 12 insertions, 11 deletions
diff --git a/gemini/response_test.go b/gemini/response_test.go
index 616fac4..9287d71 100644
--- a/gemini/response_test.go
+++ b/gemini/response_test.go
@@ -6,14 +6,15 @@ import (
"io"
"testing"
+ "tildegit.org/tjp/gus"
"tildegit.org/tjp/gus/gemini"
)
func TestBuildResponses(t *testing.T) {
table := []struct {
name string
- response *gemini.Response
- status gemini.Status
+ response *gus.Response
+ status gus.Status
meta string
body string
}{
@@ -137,7 +138,7 @@ func TestBuildResponses(t *testing.T) {
t.Errorf("expected meta %q, got %q", test.meta, test.response.Meta)
}
- responseBytes, err := io.ReadAll(test.response)
+ responseBytes, err := io.ReadAll(gemini.NewResponseReader(test.response))
if err != nil {
t.Fatalf("error reading response body: %q", err.Error())
}
@@ -153,7 +154,7 @@ func TestBuildResponses(t *testing.T) {
func TestParseResponses(t *testing.T) {
table := []struct {
input string
- status gemini.Status
+ status gus.Status
meta string
body string
err error
@@ -232,7 +233,7 @@ func TestParseResponses(t *testing.T) {
func TestResponseClose(t *testing.T) {
body := &rdCloser{Buffer: bytes.NewBufferString("the body here")}
- resp := &gemini.Response{
+ resp := &gus.Response{
Status: gemini.StatusSuccess,
Meta: "text/gemini",
Body: body,
@@ -246,7 +247,7 @@ func TestResponseClose(t *testing.T) {
t.Error("response body was not closed by response.Close()")
}
- resp = &gemini.Response{
+ resp = &gus.Response{
Status: gemini.StatusInput,
Meta: "give me more",
}
@@ -269,8 +270,8 @@ func (rc *rdCloser) Close() error {
func TestResponseWriteTo(t *testing.T) {
// invariant under test: WriteTo() sends the same bytes as Read()
- clone := func(resp *gemini.Response) *gemini.Response {
- other := &gemini.Response{
+ clone := func(resp *gus.Response) *gus.Response {
+ other := &gus.Response{
Status: resp.Status,
Meta: resp.Meta,
}
@@ -296,7 +297,7 @@ func TestResponseWriteTo(t *testing.T) {
table := []struct {
name string
- response *gemini.Response
+ response *gus.Response
}{
{
name: "simple success",
@@ -316,13 +317,13 @@ func TestResponseWriteTo(t *testing.T) {
r1 := test.response
r2 := clone(test.response)
- rdbuf, err := io.ReadAll(r1)
+ rdbuf, err := io.ReadAll(gemini.NewResponseReader(r1))
if err != nil {
t.Fatalf("response.Read(): %s", err.Error())
}
wtbuf := &bytes.Buffer{}
- if _, err := r2.WriteTo(wtbuf); err != nil {
+ if _, err := gemini.NewResponseReader(r2).WriteTo(wtbuf); err != nil {
t.Fatalf("response.WriteTo(): %s", err.Error())
}