feat(metadata): enhance metadata handling by sanitizing extracted data and updating documentation for file storage
This commit is contained in:
28
internal/tools/files_test.go
Normal file
28
internal/tools/files_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package tools
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestDecodeBase64AcceptsWhitespaceAndMultipleVariants(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
want string
|
||||
}{
|
||||
{name: "standard with whitespace", input: "aG V s\nbG8=", want: "hello"},
|
||||
{name: "raw standard", input: "aGVsbG8", want: "hello"},
|
||||
{name: "standard url-safe payload", input: "--8=", want: string([]byte{0xfb, 0xef})},
|
||||
{name: "raw url-safe payload", input: "--8", want: string([]byte{0xfb, 0xef})},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
got, err := decodeBase64(tc.input)
|
||||
if err != nil {
|
||||
t.Fatalf("decodeBase64(%q) error = %v", tc.input, err)
|
||||
}
|
||||
if string(got) != tc.want {
|
||||
t.Fatalf("decodeBase64(%q) = %q, want %q", tc.input, string(got), tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user