优化代码

This commit is contained in:
GoEdgeLab
2022-09-23 09:28:19 +08:00
parent ebe5960731
commit 63a4c4c730
20 changed files with 90 additions and 58 deletions

View File

@@ -3,21 +3,21 @@
package services
import (
"github.com/TeaOSLab/EdgeAPI/internal/utils"
"github.com/iwind/TeaGo/assert"
"testing"
)
func TestHTTPCacheTaskService_CountHTTPCacheTasks(t *testing.T) {
func TestHTTPCacheTaskService_ParseDomain(t *testing.T) {
var a = assert.NewAssertion(t)
var service = &HTTPCacheTaskService{}
a.IsTrue(service.parseDomain("aaa") == "aaa")
a.IsTrue(service.parseDomain("AAA") == "aaa")
a.IsTrue(service.parseDomain("a.b-c.com") == "a.b-c.com")
a.IsTrue(service.parseDomain("a.b-c.com/hello/world") == "a.b-c.com")
a.IsTrue(service.parseDomain("https://a.b-c.com") == "a.b-c.com")
a.IsTrue(service.parseDomain("http://a.b-c.com/hello/world") == "a.b-c.com")
a.IsTrue(service.parseDomain("http://a.B-c.com/hello/world") == "a.b-c.com")
a.IsTrue(service.parseDomain("http:/aaaa.com") == "http")
a.IsTrue(service.parseDomain("北京") == "")
a.IsTrue(utils.ParseDomainFromKey("aaa") == "aaa")
a.IsTrue(utils.ParseDomainFromKey("AAA") == "aaa")
a.IsTrue(utils.ParseDomainFromKey("a.b-c.com") == "a.b-c.com")
a.IsTrue(utils.ParseDomainFromKey("a.b-c.com/hello/world") == "a.b-c.com")
a.IsTrue(utils.ParseDomainFromKey("https://a.b-c.com") == "a.b-c.com")
a.IsTrue(utils.ParseDomainFromKey("http://a.b-c.com/hello/world") == "a.b-c.com")
a.IsTrue(utils.ParseDomainFromKey("http://a.B-c.com/hello/world") == "a.b-c.com")
a.IsTrue(utils.ParseDomainFromKey("http:/aaaa.com") == "http")
a.IsTrue(utils.ParseDomainFromKey("北京") == "")
}