Files
rest-server/vendor/goji.io/pattern/pattern_test.go
Alexander Neumann 6054876201 Vendor dependencies
2016-12-30 18:34:37 +01:00

39 lines
686 B
Go

package pattern
import (
"context"
"net/http"
"testing"
)
type boolPattern bool
func (b boolPattern) Match(ctx context.Context, r *http.Request) context.Context {
if b {
return ctx
}
return nil
}
type prefixPattern string
func (p prefixPattern) Match(ctx context.Context, r *http.Request) context.Context {
return ctx
}
func (p prefixPattern) PathPrefix() string {
return string(p)
}
func TestPathRoundTrip(t *testing.T) {
t.Parallel()
ctx := SetPath(context.Background(), "hi")
if path := Path(ctx); path != "hi" {
t.Errorf("expected hi, got %q", path)
}
if path := Path(context.Background()); path != "" {
t.Errorf("expected empty path, got %q", path)
}
}