diff options
author | tjp <tjp@ctrl-c.club> | 2023-11-13 07:58:02 -0700 |
---|---|---|
committer | tjp <tjp@ctrl-c.club> | 2023-11-13 07:58:02 -0700 |
commit | e599f0e2d4f8177143478ba17189e1ef656b7fe0 (patch) | |
tree | 2ed812e69f16e5b599298392ad54a3009778c4f1 /contrib/sharedhost/replacement_test.go | |
parent | aa9bca810912f102a13a674ee30bf97f5667f662 (diff) |
remove the old contrib/sharedhost replacement approach
Diffstat (limited to 'contrib/sharedhost/replacement_test.go')
-rw-r--r-- | contrib/sharedhost/replacement_test.go | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/contrib/sharedhost/replacement_test.go b/contrib/sharedhost/replacement_test.go deleted file mode 100644 index 9fa9161..0000000 --- a/contrib/sharedhost/replacement_test.go +++ /dev/null @@ -1,57 +0,0 @@ -package sharedhost_test - -import ( - "context" - "net/url" - "testing" - - "github.com/stretchr/testify/assert" - - sr "tildegit.org/tjp/sliderule" - "tildegit.org/tjp/sliderule/contrib/sharedhost" -) - -func TestReplaceTilde(t *testing.T) { - tests := []struct { - replacement string - inputURL string - replacedPath string - }{ - { - replacement: "users/", - inputURL: "gemini://domain.com/~username/foo/bar", - replacedPath: "/users/username/foo/bar", - }, - { - replacement: "people-", - inputURL: "gemini://domain.com/non/match", - replacedPath: "/non/match", - }, - { - replacement: "people-", - inputURL: "gemini://domain.com/~someone/dir/file", - replacedPath: "/people-someone/dir/file", - }, - } - - for _, test := range tests { - t.Run(test.inputURL, func(t *testing.T) { - u, err := url.Parse(test.inputURL) - assert.Nil(t, err) - - originalPath := u.Path - - replacer := sharedhost.ReplaceTilde(test.replacement) - request := &sr.Request{URL: u} - handler := replacer(sr.HandlerFunc(func(_ context.Context, request *sr.Request) *sr.Response { - assert.Equal(t, test.replacedPath, request.Path) - return &sr.Response{} - })) - - handler.Handle(context.Background(), request) - - // original request was unmodified - assert.Equal(t, originalPath, request.Path) - }) - } -} |