Files
EdgeCommon/pkg/serverconfigs/http_access_log_ref_test.go

47 lines
1018 B
Go
Raw Permalink Normal View History

2020-09-20 11:56:22 +08:00
package serverconfigs
import (
"testing"
2024-07-27 13:29:26 +08:00
"github.com/iwind/TeaGo/assert"
2020-09-20 11:56:22 +08:00
)
func TestHTTPAccessLogConfig_Match(t *testing.T) {
a := assert.NewAssertion(t)
{
2020-09-20 16:27:59 +08:00
accessLog := NewHTTPAccessLogRef()
2020-09-20 11:56:22 +08:00
a.IsNil(accessLog.Init())
a.IsTrue(accessLog.Match(100))
a.IsTrue(accessLog.Match(200))
a.IsTrue(accessLog.Match(300))
a.IsTrue(accessLog.Match(400))
a.IsTrue(accessLog.Match(500))
}
{
2020-09-20 16:27:59 +08:00
accessLog := NewHTTPAccessLogRef()
2020-09-20 11:56:22 +08:00
accessLog.Status1 = false
accessLog.Status2 = false
a.IsNil(accessLog.Init())
a.IsFalse(accessLog.Match(100))
a.IsFalse(accessLog.Match(200))
a.IsTrue(accessLog.Match(300))
a.IsTrue(accessLog.Match(400))
a.IsTrue(accessLog.Match(500))
}
{
2020-09-20 16:27:59 +08:00
accessLog := NewHTTPAccessLogRef()
2020-09-20 11:56:22 +08:00
accessLog.Status3 = false
accessLog.Status4 = false
accessLog.Status5 = false
a.IsNil(accessLog.Init())
a.IsTrue(accessLog.Match(100))
a.IsTrue(accessLog.Match(200))
a.IsFalse(accessLog.Match(300))
a.IsFalse(accessLog.Match(400))
a.IsFalse(accessLog.Match(500))
}
}