Skip to content

Route.Find match error #225

Closed
Closed
@SuperGod

Description

func TestAPIMatchAll(t *testing.T) {
	domain1 := "baidu.com"
	params := make(map[string][]byte, 0)
	paramsFunc := func(name, value []byte) {
		params[string(name)] = value
	}
	var id uint64
	r := NewRoute()

	r.Add(&metapb.API{
		ID:         1,
		MatchRule:  metapb.MatchAll,
		URLPattern: "/a/b/c",
		Method:     "POST",
		Domain:     domain1,
	})

	id, ret := r.Find([]byte("/a/b/d/c"), "POST", paramsFunc)
	if !ret {
		t.Fatal(ret)
		return
	}
	if id != 1 {
		t.Errorf("expect matched 1, but %d", id)
	}
}

我理解的这个go test应该会失败,但是这个test pass了,所以这是一个bug,还是一个feature?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions