github.com/sandwich-go/boost@v1.3.29/xrand/string_test.go (about)

     1  package xrand
     2  
     3  import (
     4  	. "github.com/smartystreets/goconvey/convey"
     5  	"strings"
     6  	"testing"
     7  	"time"
     8  )
     9  
    10  func TestRandString(t *testing.T) {
    11  	Convey("rand string", t, func() {
    12  		ss := String(10)
    13  		t.Log(ss)
    14  		So(len(ss), ShouldEqual, 10)
    15  
    16  		t0 := time.Unix(1000000, 0)
    17  		nowFunc = func() time.Time {
    18  			return t0
    19  		}
    20  		ss = StringWithTimestamp(10)
    21  		So(strings.HasSuffix(ss, "1000000"), ShouldBeTrue)
    22  	})
    23  }