mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-23 22:27:38 -05:00
Preliminary test case for setup/config/ext.go
This commit is contained in:
parent
3418770fe1
commit
2175c68319
1 changed files with 31 additions and 0 deletions
31
config/setup/ext_test.go
Normal file
31
config/setup/ext_test.go
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
package setup
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/mholt/caddy/middleware/gzip"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestExt(t *testing.T) {
|
||||||
|
c := newTestController(`ext .html .htm .php`)
|
||||||
|
|
||||||
|
mid, err := Ext(c)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Expected no errors, got: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if mid == nil {
|
||||||
|
t.Fatal("Expected middleware, was nil instead")
|
||||||
|
}
|
||||||
|
|
||||||
|
handler := mid(emptyNext)
|
||||||
|
myHandler, ok := handler.(ext.Ext)
|
||||||
|
if !ok {
|
||||||
|
t.Fatalf("Expected handler to be type Ext, got: %#v", handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !sameNext(myHandler.Next, emptyNext) {
|
||||||
|
t.Error("'Next' field of handler was not set properly")
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue