mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-23 22:27:38 -05:00
Added Assertions
Added assertions to check for the extensions in the order specified
This commit is contained in:
parent
2a166f088d
commit
d7db1b9576
1 changed files with 13 additions and 5 deletions
|
@ -2,8 +2,8 @@ package setup
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/mholt/caddy/middleware/ext"
|
"github.com/mholt/caddy/middleware/extensions"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestExt(t *testing.T) {
|
func TestExt(t *testing.T) {
|
||||||
|
@ -20,12 +20,20 @@ func TestExt(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
handler := mid(emptyNext)
|
handler := mid(emptyNext)
|
||||||
myHandler, ok := handler.(ext.Ext)
|
myHandler, ok := handler.(extensions.Ext)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("Expected handler to be type Ext, got: %#v", handler)
|
t.Fatalf("Expected handler to be type Ext, got: %#v", handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !sameNext(myHandler.Next, emptyNext) {
|
if myHandler.Extensions[0] != ".html" {
|
||||||
t.Error("'Next' field of handler was not set properly")
|
t.Errorf("Expected .html in the list of Extensions")
|
||||||
}
|
}
|
||||||
|
if myHandler.Extensions[1] != ".htm" {
|
||||||
|
t.Errorf("Expected .htm in the list of Extensions")
|
||||||
|
}
|
||||||
|
if myHandler.Extensions[2] != ".php" {
|
||||||
|
t.Errorf("Expected .php in the list of Extensions")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue