This commit is contained in:
58
e2e/go/mime_utilities_test.go
generated
Normal file
58
e2e/go/mime_utilities_test.go
generated
Normal file
@@ -0,0 +1,58 @@
|
||||
// This file is auto-generated by alef — DO NOT EDIT.
|
||||
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
|
||||
// To regenerate: alef generate
|
||||
// To verify freshness: alef verify --exit-code
|
||||
// Issues & docs: https://github.com/kreuzberg-dev/alef
|
||||
|
||||
// E2e tests for category: mime_utilities
|
||||
package e2e_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
kreuzberg "github.com/kreuzberg-dev/kreuzberg/v5"
|
||||
)
|
||||
|
||||
func Test_MimeDetectBytes(t *testing.T) {
|
||||
// Detect MIME type from file bytes
|
||||
contentBytes, contentBytesErr := os.ReadFile(`pdf/fake_memo.pdf`)
|
||||
if contentBytesErr != nil {
|
||||
t.Fatalf("read fixture pdf/fake_memo.pdf: %v", contentBytesErr)
|
||||
}
|
||||
result, err := kreuzberg.DetectMimeTypeFromBytes(contentBytes)
|
||||
if err != nil {
|
||||
t.Fatalf("call failed: %v", err)
|
||||
}
|
||||
if !strings.Contains(string(result), `pdf`) {
|
||||
t.Errorf("expected to contain %s, got %v", `pdf`, result)
|
||||
}
|
||||
}
|
||||
|
||||
func Test_MimeDetectImage(t *testing.T) {
|
||||
// Detect MIME type from PNG image bytes
|
||||
contentBytes, contentBytesErr := os.ReadFile(`images/test_hello_world.png`)
|
||||
if contentBytesErr != nil {
|
||||
t.Fatalf("read fixture images/test_hello_world.png: %v", contentBytesErr)
|
||||
}
|
||||
result, err := kreuzberg.DetectMimeTypeFromBytes(contentBytes)
|
||||
if err != nil {
|
||||
t.Fatalf("call failed: %v", err)
|
||||
}
|
||||
if !strings.Contains(string(result), `png`) {
|
||||
t.Errorf("expected to contain %s, got %v", `png`, result)
|
||||
}
|
||||
}
|
||||
|
||||
func Test_MimeGetExtensions(t *testing.T) {
|
||||
// Get file extensions for a MIME type
|
||||
result, err := kreuzberg.GetExtensionsForMime(`application/pdf`)
|
||||
if err != nil {
|
||||
t.Fatalf("call failed: %v", err)
|
||||
}
|
||||
value := result
|
||||
if !strings.Contains(jsonString(value), `pdf`) {
|
||||
t.Errorf("expected to contain %s, got %v", `pdf`, value)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user