mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2026-01-07 04:25:50 +08:00
实现缓存策略若干功能
This commit is contained in:
76
pkg/serverconfigs/http_cache_policy_test.go
Normal file
76
pkg/serverconfigs/http_cache_policy_test.go
Normal file
@@ -0,0 +1,76 @@
|
||||
package serverconfigs
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
"github.com/iwind/TeaGo/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHTTPCachePolicy_IsSame(t *testing.T) {
|
||||
a := assert.NewAssertion(t)
|
||||
{
|
||||
p1 := &HTTPCachePolicy{}
|
||||
p2 := &HTTPCachePolicy{}
|
||||
a.IsTrue(p1.IsSame(p2))
|
||||
}
|
||||
{
|
||||
p1 := &HTTPCachePolicy{
|
||||
Capacity: &shared.SizeCapacity{
|
||||
Count: 0,
|
||||
Unit: "",
|
||||
},
|
||||
}
|
||||
p2 := &HTTPCachePolicy{}
|
||||
a.IsFalse(p1.IsSame(p2))
|
||||
}
|
||||
{
|
||||
p1 := &HTTPCachePolicy{
|
||||
Capacity: &shared.SizeCapacity{
|
||||
Count: 0,
|
||||
Unit: "",
|
||||
},
|
||||
}
|
||||
p2 := &HTTPCachePolicy{
|
||||
Capacity: &shared.SizeCapacity{
|
||||
Count: 0,
|
||||
Unit: "",
|
||||
},
|
||||
}
|
||||
a.IsTrue(p1.IsSame(p2))
|
||||
}
|
||||
{
|
||||
p1 := &HTTPCachePolicy{
|
||||
Options: map[string]interface{}{},
|
||||
}
|
||||
p2 := &HTTPCachePolicy{}
|
||||
a.IsFalse(p1.IsSame(p2))
|
||||
}
|
||||
{
|
||||
p1 := &HTTPCachePolicy{
|
||||
Options: map[string]interface{}{},
|
||||
}
|
||||
p2 := &HTTPCachePolicy{
|
||||
Options: map[string]interface{}{},
|
||||
}
|
||||
a.IsTrue(p1.IsSame(p2))
|
||||
}
|
||||
{
|
||||
p1 := &HTTPCachePolicy{
|
||||
Options: map[string]interface{}{
|
||||
"c": 3,
|
||||
"a": 1,
|
||||
"d": "abc",
|
||||
"b": 2,
|
||||
},
|
||||
}
|
||||
p2 := &HTTPCachePolicy{
|
||||
Options: map[string]interface{}{
|
||||
"c": 3,
|
||||
"a": 1,
|
||||
"d": "abc",
|
||||
"b": 2,
|
||||
},
|
||||
}
|
||||
a.IsTrue(p1.IsSame(p2))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user