Skip to content

Commit

Permalink
test: add more parse tests
Browse files Browse the repository at this point in the history
  • Loading branch information
crhntr committed Nov 28, 2024
1 parent d436b4d commit 24a9bb9
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions template_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,58 @@ func TestNewTemplateName(t *testing.T) {
assert.ErrorContains(t, err, "expected only identifier or call expressions as arguments, argument at index 0 is: 1 + 2")
},
},
{
Name: "status identifier",
In: "/ http.StatusTeapot",
ExpMatch: true,
TemplateName: func(t *testing.T, pat Template) {
assert.Equal(t, "", pat.method)
assert.Equal(t, "", pat.host)
assert.Equal(t, "/", pat.path)
assert.Equal(t, "/", pat.pattern)
assert.Equal(t, 418, pat.statusCode)
assert.Equal(t, "", pat.handler)
},
},
{
Name: "path and status",
In: "/ 418",
ExpMatch: true,
TemplateName: func(t *testing.T, pat Template) {
assert.Equal(t, "", pat.method)
assert.Equal(t, "", pat.host)
assert.Equal(t, "/", pat.path)
assert.Equal(t, "/", pat.pattern)
assert.Equal(t, 418, pat.statusCode)
assert.Equal(t, "", pat.handler)
},
},
{
Name: "path status and call",
In: "/ 418 f()",
ExpMatch: true,
TemplateName: func(t *testing.T, pat Template) {
assert.Equal(t, "", pat.method)
assert.Equal(t, "", pat.host)
assert.Equal(t, "/", pat.path)
assert.Equal(t, "/", pat.pattern)
assert.Equal(t, 418, pat.statusCode)
assert.Equal(t, "f()", pat.handler)
},
},
{
Name: "path and call",
In: "/ f()",
ExpMatch: true,
TemplateName: func(t *testing.T, pat Template) {
assert.Equal(t, "", pat.method)
assert.Equal(t, "", pat.host)
assert.Equal(t, "/", pat.path)
assert.Equal(t, "/", pat.pattern)
assert.Equal(t, http.StatusOK, pat.statusCode)
assert.Equal(t, "f()", pat.handler)
},
},
} {
t.Run(tt.Name, func(t *testing.T) {
pat, err, match := NewTemplateName(tt.In)
Expand Down

0 comments on commit 24a9bb9

Please sign in to comment.