mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-12-25 19:56:37 +08:00
阶段性提交
This commit is contained in:
31
pkg/serverconfigs/shared/http_header_config_test.go
Normal file
31
pkg/serverconfigs/shared/http_header_config_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package shared
|
||||
|
||||
import (
|
||||
"github.com/iwind/TeaGo/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHeaderConfig_Match(t *testing.T) {
|
||||
a := assert.NewAssertion(t)
|
||||
h := NewHeaderConfig()
|
||||
err := h.Init()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
a.IsFalse(h.Match(200))
|
||||
a.IsFalse(h.Match(400))
|
||||
|
||||
h.Status = &HTTPStatusConfig{
|
||||
Always: false,
|
||||
Codes: []int{200, 301, 302, 400},
|
||||
}
|
||||
err = h.Init()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
a.IsTrue(h.Match(400))
|
||||
a.IsFalse(h.Match(500))
|
||||
|
||||
h.Status.Always = true
|
||||
a.IsTrue(h.Match(500))
|
||||
}
|
||||
Reference in New Issue
Block a user