summaryrefslogtreecommitdiff
path: root/handler_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'handler_test.go')
-rw-r--r--handler_test.go28
1 files changed, 14 insertions, 14 deletions
diff --git a/handler_test.go b/handler_test.go
index 18ef562..048e8be 100644
--- a/handler_test.go
+++ b/handler_test.go
@@ -1,4 +1,4 @@
-package gus_test
+package sliderule_test
import (
"bytes"
@@ -8,33 +8,33 @@ import (
"strings"
"testing"
- "tildegit.org/tjp/gus"
- "tildegit.org/tjp/gus/gemini"
+ sr "tildegit.org/tjp/sliderule"
+ "tildegit.org/tjp/sliderule/gemini"
)
func TestFallthrough(t *testing.T) {
- h1 := gus.HandlerFunc(func(ctx context.Context, req *gus.Request) *gus.Response {
+ h1 := sr.HandlerFunc(func(ctx context.Context, req *sr.Request) *sr.Response {
if req.Path == "/one" {
return gemini.Success("text/gemini", bytes.NewBufferString("one"))
}
return nil
})
- h2 := gus.HandlerFunc(func(ctx context.Context, req *gus.Request) *gus.Response {
+ h2 := sr.HandlerFunc(func(ctx context.Context, req *sr.Request) *sr.Response {
if req.Path == "/two" {
return gemini.Success("text/gemini", bytes.NewBufferString("two"))
}
return nil
})
- fth := gus.FallthroughHandler(h1, h2)
+ fth := sr.FallthroughHandler(h1, h2)
u, err := url.Parse("gemini://test.local/one")
if err != nil {
t.Fatalf("url.Parse: %s", err.Error())
}
- resp := fth.Handle(context.Background(), &gus.Request{URL: u})
+ resp := fth.Handle(context.Background(), &sr.Request{URL: u})
if resp.Status != gemini.StatusSuccess {
t.Errorf("expected status %d, got %d", gemini.StatusSuccess, resp.Status)
@@ -57,7 +57,7 @@ func TestFallthrough(t *testing.T) {
t.Fatalf("url.Parse: %s", err.Error())
}
- resp = fth.Handle(context.Background(), &gus.Request{URL: u})
+ resp = fth.Handle(context.Background(), &sr.Request{URL: u})
if resp.Status != gemini.StatusSuccess {
t.Errorf("expected status %d, got %d", gemini.StatusSuccess, resp.Status)
@@ -80,7 +80,7 @@ func TestFallthrough(t *testing.T) {
t.Fatalf("url.Parse: %s", err.Error())
}
- resp = fth.Handle(context.Background(), &gus.Request{URL: u})
+ resp = fth.Handle(context.Background(), &sr.Request{URL: u})
if resp != nil {
t.Errorf("expected nil, got %+v", resp)
@@ -88,20 +88,20 @@ func TestFallthrough(t *testing.T) {
}
func TestFilter(t *testing.T) {
- pred := func(ctx context.Context, req *gus.Request) bool {
+ pred := func(ctx context.Context, req *sr.Request) bool {
return strings.HasPrefix(req.Path, "/allow")
}
- base := gus.HandlerFunc(func(ctx context.Context, req *gus.Request) *gus.Response {
+ base := sr.HandlerFunc(func(ctx context.Context, req *sr.Request) *sr.Response {
return gemini.Success("text/gemini", bytes.NewBufferString("allowed!"))
})
- handler := gus.Filter(pred, nil)(base)
+ handler := sr.Filter(pred, nil)(base)
u, err := url.Parse("gemini://test.local/allow/please")
if err != nil {
t.Fatalf("url.Parse: %s", err.Error())
}
- resp := handler.Handle(context.Background(), &gus.Request{URL: u})
+ resp := handler.Handle(context.Background(), &sr.Request{URL: u})
if resp.Status != gemini.StatusSuccess {
t.Errorf("expected status %d, got %d", gemini.StatusSuccess, resp.Status)
}
@@ -111,7 +111,7 @@ func TestFilter(t *testing.T) {
t.Fatalf("url.Parse: %s", err.Error())
}
- resp = handler.Handle(context.Background(), &gus.Request{URL: u})
+ resp = handler.Handle(context.Background(), &sr.Request{URL: u})
if resp != nil {
t.Errorf("expected nil, got %+v", resp)
}