mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-03 20:40:25 +08:00
44 lines
882 B
Go
44 lines
882 B
Go
package serverconfigs
|
|
|
|
import (
|
|
"github.com/iwind/TeaGo/assert"
|
|
"testing"
|
|
)
|
|
|
|
func TestGzipConfig_MatchContentType(t *testing.T) {
|
|
a := assert.NewAssertion(t)
|
|
|
|
{
|
|
gzip := &HTTPGzipConfig{}
|
|
a.IsNil(gzip.Init())
|
|
a.IsTrue(gzip.MatchContentType("text/html"))
|
|
}
|
|
|
|
{
|
|
gzip := &HTTPGzipConfig{}
|
|
a.IsNil(gzip.Init())
|
|
a.IsTrue(gzip.MatchContentType("text/html; charset=utf-8"))
|
|
}
|
|
|
|
{
|
|
gzip := &HTTPGzipConfig{}
|
|
gzip.MimeTypes = []string{"text/*"}
|
|
a.IsNil(gzip.Init())
|
|
a.IsTrue(gzip.MatchContentType("text/html; charset=utf-8"))
|
|
}
|
|
|
|
{
|
|
gzip := &HTTPGzipConfig{}
|
|
gzip.MimeTypes = []string{"text/*"}
|
|
a.IsNil(gzip.Init())
|
|
a.IsFalse(gzip.MatchContentType("application/json; charset=utf-8"))
|
|
}
|
|
|
|
{
|
|
gzip := &HTTPGzipConfig{}
|
|
gzip.MimeTypes = []string{"text/*", "image/*"}
|
|
a.IsNil(gzip.Init())
|
|
a.IsTrue(gzip.MatchContentType("image/jpeg; charset=utf-8"))
|
|
}
|
|
}
|