package test import ( imageDomain "RenewCMS/internal/domain/image" "RenewCMS/internal/infrastructure/storage" "path/filepath" "reflect" "strings" "testing" ) func TestLocalStorageHasAnExtensionForEveryAllowedContentType(t *testing.T) { store := storage.NewLocalStorage(t.TempDir()) allowedContentTypes := imageDomain.AllowedContentTypes() expectedContentTypes := []string{"image/jpeg", "image/png", "image/svg+xml", "image/webp"} if !reflect.DeepEqual(allowedContentTypes, expectedContentTypes) { t.Fatalf("expected AllowedContentTypes() to be %v, got %v", expectedContentTypes, allowedContentTypes) } for _, contentType := range allowedContentTypes { t.Run(contentType, func(t *testing.T) { storedName, err := store.Put(contentType, strings.NewReader("fake-image-data")) if err != nil { t.Fatalf("Put failed: %v", err) } if filepath.Ext(storedName) == "" { t.Errorf("expected a non-empty extension for %q, got name %q", contentType, storedName) } }) } }