package logid

import (
	"testing"
	"time"

	. "github.com/smartystreets/goconvey/convey"
)

func TestGenerateLogidWithTime(t *testing.T) {
	Convey("TestGenerateLogidWithTime", t, func() {
		Convey("should have expected length and special prefix", func() {
			now := time.Date(2021, 03, 04, 05, 06, 07, 0, time.Local)
			r1 := GenerateLogidWithTime(now)
			So(r1, ShouldHaveLength, 34)
			So(r1, ShouldStartWith, "20210304050607")
		})
		Convey("should generate unique logid", func() {
			now := time.Now()
			r1 := GenerateLogidWithTime(now)
			r2 := GenerateLogidWithTime(now)
			So(r1, ShouldNotEqual, r2)
		})
	})
}
