github.com/blend/go-sdk@v1.20220411.3/consistenthash/stable_hash_test.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package consistenthash 9 10 import ( 11 "testing" 12 13 "github.com/blend/go-sdk/assert" 14 ) 15 16 func Test_StableHash_isStable(t *testing.T) { 17 its := assert.New(t) 18 19 testCases := [...]struct { 20 Input string 21 Expected uint64 22 }{ 23 {Input: "foo-bar-baz", Expected: 0x3bcce3e4ec07ffbc}, 24 {Input: "google.com", Expected: 0x1c1766d80c8f9809}, 25 {Input: "worker-5", Expected: 0xd95dff1c56889f11}, 26 {Input: "worker-5|0", Expected: 0xffbfaa9d0532a241}, 27 } 28 29 for _, testCase := range testCases { 30 its.Equal(testCase.Expected, StableHash([]byte(testCase.Input))) 31 } 32 }