Skip to content

Commit

Permalink
hash: add UT for HashString
Browse files Browse the repository at this point in the history
Signed-off-by: Zhou Hao <zhouhao@cn.fujitsu.com>
  • Loading branch information
Zhou Hao committed Apr 23, 2020
1 parent 6e3eda7 commit d9baa8f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions upup/pkg/fi/utils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ go_test(
name = "go_default_test",
srcs = [
"equals_test.go",
"hash_test.go",
"sanitize_test.go",
],
embed = [":go_default_library"],
Expand Down
40 changes: 40 additions & 0 deletions upup/pkg/fi/utils/hash_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
Copyright 2019 The Kubernetes Authors.
Licensed 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 utils

import (
"testing"
)

func TestSanitizeString(t *testing.T) {
tests := []struct {
s string
expectedStr string
}{
{
s: "test",
expectedStr: "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3",
},
}

for _, test := range tests {
result, _ := HashString(test.s)
if test.expectedStr != result {
t.Errorf("Expected %s, got %s", test.expectedStr, result)
}
}
}

0 comments on commit d9baa8f

Please sign in to comment.