git-hulk commented on code in PR #3313: URL: https://github.com/apache/kvrocks/pull/3313#discussion_r2649171241
########## tests/gocase/unit/type/string/digest_test.go: ########## @@ -0,0 +1,172 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package string + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/apache/kvrocks/tests/gocase/util" +) + +func TestDigest(t *testing.T) { + srv := util.StartServer(t, map[string]string{}) + defer srv.Close() + ctx := context.Background() + rdb := srv.NewClient() + defer func() { require.NoError(t, rdb.Close()) }() + + t.Run("DIGEST with existing string key", func(t *testing.T) { + require.NoError(t, rdb.Set(ctx, "key1", "Hello world", 0).Err()) + + // DIGEST should return hex hash + digest := rdb.Do(ctx, "DIGEST", "key1").String() + require.NotEmpty(t, digest) + + // Result should be a string with 16 hex characters + require.Len(t, digest, 16) + + // Verify it contains only valid hex characters + for _, c := range digest { + require.True(t, (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')) + } Review Comment: Add a fixed digest test case to make sure it uses the same hash algorithm as Redis. ```suggestion require.Equal(t, "b6acb9d84a38ff74", digest) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
