From 7a78ebee78bf26e4b57ada49aa6c7a13edbbad6c Mon Sep 17 00:00:00 2001 From: Ryan Gang Date: Thu, 12 Dec 2024 13:03:08 +0530 Subject: [PATCH] refactor: replace custom random integer function with tester-utils method --- protocol/common/constants.go | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/protocol/common/constants.go b/protocol/common/constants.go index 510c6ed..119819a 100644 --- a/protocol/common/constants.go +++ b/protocol/common/constants.go @@ -2,7 +2,6 @@ package common import ( "fmt" - "slices" "sort" "github.com/codecrafters-io/tester-utils/random" @@ -26,7 +25,7 @@ var ( TOPIC1_NAME = topic_names[0] TOPIC2_NAME = topic_names[1] TOPIC3_NAME = topic_names[2] - random_topic_uuids = getUniqueRandomIntegers(10, 99, 3) + random_topic_uuids = random.RandomUniqueInts(10, 100, 3) TOPIC1_UUID = fmt.Sprintf("00000000-0000-4000-8000-0000000000%02d", random_topic_uuids[0]) TOPIC2_UUID = fmt.Sprintf("00000000-0000-4000-8000-0000000000%02d", random_topic_uuids[1]) TOPIC3_UUID = fmt.Sprintf("00000000-0000-4000-8000-0000000000%02d", random_topic_uuids[2]) @@ -48,15 +47,3 @@ func GetSortedValues[T string](values []T) []T { }) return values } - -func getUniqueRandomIntegers(min, max, count int) []int { - randomInts := []int{} - for i := 0; i < count; i++ { - randomInt := random.RandomInt(min, max) - for slices.Contains(randomInts, randomInt) { - randomInt = random.RandomInt(min, max) - } - randomInts = append(randomInts, randomInt) - } - return randomInts -}