30 lines
611 B
Go
30 lines
611 B
Go
package main_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
"github.com/speps/go-hashids/v2"
|
|
)
|
|
|
|
func Test_hassID(t *testing.T) {
|
|
Convey("test_hassID", t, func() {
|
|
Convey("step 1", func() {
|
|
data := hashids.NewData()
|
|
data.MinLength = 6
|
|
data.Salt = "xixi0202"
|
|
data.Alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
hashId, err := hashids.NewWithData(data)
|
|
So(err, ShouldBeNil)
|
|
So(hashId, ShouldNotBeNil)
|
|
|
|
item := []int{1, 2}
|
|
str, err := hashId.Encode(item)
|
|
|
|
So(err, ShouldBeNil)
|
|
So(str, ShouldNotBeEmpty)
|
|
t.Logf("ids:%+v %s", item, str)
|
|
})
|
|
})
|
|
}
|