Skip to content

Commit

Permalink
add tests for generatePointerHash
Browse files Browse the repository at this point in the history
  • Loading branch information
nhulston committed Feb 7, 2025
1 parent f74fcae commit 74b3b21
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions contrib/aws/internal/span_pointers/span_pointers_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package span_pointers

import (
"testing"
)

func TestGeneratePointerHash(t *testing.T) {
tests := []struct {
name string
components []string
expectedHash string
}{
{
name: "basic values",
components: []string{
"some-bucket",
"some-key.data",
"ab12ef34",
},
expectedHash: "e721375466d4116ab551213fdea08413",
},
{
name: "non-ascii key",
components: []string{
"some-bucket",
"some-key.你好",
"ab12ef34",
},
expectedHash: "d1333a04b9928ab462b5c6cadfa401f4",
},
{
name: "multipart-upload",
components: []string{
"some-bucket",
"some-key.data",
"ab12ef34-5",
},
expectedHash: "2b90dffc37ebc7bc610152c3dc72af9f",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := generatePointerHash(tt.components)
if got != tt.expectedHash {
t.Errorf("GeneratePointerHash() = %v, want %v", got, tt.expectedHash)
}
})
}
}

0 comments on commit 74b3b21

Please sign in to comment.