diff options
author | tjpcc <tjp@ctrl-c.club> | 2023-05-01 07:56:25 -0600 |
---|---|---|
committer | tjpcc <tjp@ctrl-c.club> | 2023-05-01 07:56:25 -0600 |
commit | 9a2da81b11ad0064cca24ce7974827d032309369 (patch) | |
tree | 4313224dc089208423e78bffc3ec50833e35bcea /handler_test.go | |
parent | 21e2758145d100d74013060f7090d84679cae683 (diff) |
name change gus -> sliderule
Diffstat (limited to 'handler_test.go')
-rw-r--r-- | handler_test.go | 28 |
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) } |