You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
988 B
Go
56 lines
988 B
Go
package pusher
|
|
|
|
import (
|
|
"context"
|
|
_ "joybuywork/test"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/rs/xid"
|
|
)
|
|
|
|
func TestGroup(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
|
|
|
for i := 0; i < 100; i++ {
|
|
id := xid.New().String()
|
|
|
|
var at int64 = 1772703600
|
|
t.Run("one", func(t *testing.T) {
|
|
ti, _ := time.ParseInLocation("2006-01-02 15:04:05", "2026-03-05 17:40:01", time.Local)
|
|
|
|
pg := newPushGroup(ctx, ti, 1, "a")
|
|
|
|
if pg.insideThree(at) {
|
|
pg.three.Set(id, "1")
|
|
} else if pg.insideTwo(at) {
|
|
pg.two.Set(id, "1")
|
|
} else if pg.insideOne(at) {
|
|
pg.one.Set(id, "1")
|
|
}
|
|
})
|
|
|
|
t.Run("two", func(t *testing.T) {
|
|
ti, _ := time.ParseInLocation("2006-01-02 15:04:05", "2026-03-05 17:45:01", time.Local)
|
|
|
|
pg := newPushGroup(ctx, ti, 1, "a")
|
|
|
|
if pg.insideOne(at) && pg.one.Exist(id) {
|
|
return
|
|
}
|
|
|
|
if pg.insideTwo(at) && pg.two.Exist(id) {
|
|
return
|
|
}
|
|
|
|
if pg.insideThree(at) && pg.three.Exist(id) {
|
|
return
|
|
}
|
|
|
|
t.Log("2323423dsfsfsdf")
|
|
})
|
|
}
|
|
|
|
}
|