refactor: id pattern heuman readable
This commit is contained in:
parent
26eb5101f9
commit
8f1d453f72
@ -166,8 +166,8 @@ func NewDateBasedGenerator() *DateBasedGenerator {
|
|||||||
return &DateBasedGenerator{
|
return &DateBasedGenerator{
|
||||||
muCpt: sync.Mutex{},
|
muCpt: sync.Mutex{},
|
||||||
cpt: 0,
|
cpt: 0,
|
||||||
idTemplate: "%s-%d",
|
idTemplate: "%s_%d",
|
||||||
start: time.Now().Format("200601021504"),
|
start: time.Now().Format("2006-01-02T15-04"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ func loadImage(t *testing.T, imgPath string, id string) *events.FrameMessage {
|
|||||||
func TestDateBasedGenerator_Next(t *testing.T) {
|
func TestDateBasedGenerator_Next(t *testing.T) {
|
||||||
log.SetLevel(log.InfoLevel)
|
log.SetLevel(log.InfoLevel)
|
||||||
|
|
||||||
expectedFmt := "[0-9]{4}[01][0-9][0-3][0-9][0-2][0-9][0-5][0-9]-[0-9]+"
|
expectedFmt := "[0-9]{4}-[01][0-9]-[0-3][0-9]T[0-2][0-9]-[0-5][0-9]_[0-9]+"
|
||||||
r, err := regexp.Compile(expectedFmt)
|
r, err := regexp.Compile(expectedFmt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to compile expected regex: %v", err)
|
t.Fatalf("unable to compile expected regex: %v", err)
|
||||||
@ -144,14 +144,14 @@ func TestDateBasedGenerator_Next(t *testing.T) {
|
|||||||
id2 := d.Next()
|
id2 := d.Next()
|
||||||
log.Debugf("2nd id: %v", id2)
|
log.Debugf("2nd id: %v", id2)
|
||||||
|
|
||||||
if strings.Split(id1, "-")[0] != strings.Split(id2, "-")[0] {
|
if strings.Split(id1, "_")[0] != strings.Split(id2, "_")[0] {
|
||||||
t.Errorf("ids are differentt prefixes: %v - %v", strings.Split(id1, "-")[0], strings.Split(id2, "-")[0])
|
t.Errorf("ids are differentt prefixes: %v - %v", strings.Split(id1, "-")[0], strings.Split(id2, "-")[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Split(id1, "-")[1] != "1" {
|
if strings.Split(id1, "_")[1] != "1" {
|
||||||
t.Errorf("unexpected suffix: %v, wants %v", strings.Split(id1, "-")[1], "1")
|
t.Errorf("unexpected suffix: %v, wants %v", strings.Split(id1, "-")[1], "1")
|
||||||
}
|
}
|
||||||
if strings.Split(id2, "-")[1] != "2" {
|
if strings.Split(id2, "_")[1] != "2" {
|
||||||
t.Errorf("unexpected suffix: %v, wants %v", strings.Split(id2, "-")[1], "2")
|
t.Errorf("unexpected suffix: %v, wants %v", strings.Split(id2, "-")[1], "2")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user