* Update all import paths * Rename directory cmd/wpcomposer/ → cmd/wppackages/ * Rename import alias wpcomposergo → wppackagesgo in main.go and migrate_test.go * Makefile — binary name wpcomposer → wppackages * Update Air path * Global replace repo.wp-composer.com → repo.wp-packages.org * Global replace cdn.wp-composer.com → cdn.wp-packages.org * Global replace wp-composer.com → wp-packages.org (remaining) * Composer repo key in templates/docs: repositories.wp-composer → repositories.wp-packages * Rename columns on the existing schema * Update all Go code referencing these column names * Routes & SEO * Templates & front-end * Admin UI * Documentation * CI/CD * Config defaults * Rename role directory * Rename all systemd template files inside the role * Update contents of all .j2 templates — service names, binary paths, descriptions * Update tasks/main.yml and handlers/main.yml in the role * Update deploy/ansible/roles/app/tasks/main.yml and deploy.yml * Update deploy/ansible/group_vars/production/main.yml * Additional renames/fixes * Additional renames/fixes * Additional renames/fixes * not needed
71 lines
2.3 KiB
Go
71 lines
2.3 KiB
Go
package og
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestGeneratePackageImage(t *testing.T) {
|
|
data := PackageData{
|
|
DisplayName: "WooCommerce",
|
|
Name: "woocommerce",
|
|
Type: "plugin",
|
|
CurrentVersion: "9.6.2",
|
|
Description: "An open-source eCommerce plugin for WordPress. Build any commerce solution with the customizability and flexibility of WordPress.",
|
|
ActiveInstalls: "5M+",
|
|
WpPackagesInstalls: "1.2K",
|
|
}
|
|
|
|
pngBytes, err := GeneratePackageImage(data)
|
|
if err != nil {
|
|
t.Fatalf("GeneratePackageImage: %v", err)
|
|
}
|
|
|
|
if len(pngBytes) < 1000 {
|
|
t.Fatalf("PNG too small: %d bytes", len(pngBytes))
|
|
}
|
|
|
|
// Write to temp for visual inspection
|
|
if os.Getenv("OG_WRITE_TEST") != "" {
|
|
_ = os.WriteFile("/tmp/og-test-package.png", pngBytes, 0o644)
|
|
t.Logf("wrote /tmp/og-test-package.png (%d bytes)", len(pngBytes))
|
|
}
|
|
}
|
|
|
|
func TestGeneratePackageImageLongDesc(t *testing.T) {
|
|
data := PackageData{
|
|
DisplayName: "Hello Elementor",
|
|
Name: "hello-elementor",
|
|
Type: "theme",
|
|
CurrentVersion: "3.4.6",
|
|
Description: "Hello Elementor is a lightweight and minimalist WordPress theme that was built specifically to work seamlessly with the Elementor site builder plugin. The theme is free, open-source, and designed for users who want a flexible, easy-to-use, and customizable website. The theme, which is optimized for performance, provides a solid foundation for users to build their own unique designs using the Elementor drag-and-drop site builder.",
|
|
ActiveInstalls: "1.0M",
|
|
WpPackagesInstalls: "0",
|
|
}
|
|
|
|
pngBytes, err := GeneratePackageImage(data)
|
|
if err != nil {
|
|
t.Fatalf("GeneratePackageImage: %v", err)
|
|
}
|
|
|
|
if os.Getenv("OG_WRITE_TEST") != "" {
|
|
_ = os.WriteFile("/tmp/og-test-long.png", pngBytes, 0o644)
|
|
t.Logf("wrote /tmp/og-test-long.png (%d bytes)", len(pngBytes))
|
|
}
|
|
}
|
|
|
|
func TestGenerateFallbackImage(t *testing.T) {
|
|
pngBytes, err := GenerateFallbackImage()
|
|
if err != nil {
|
|
t.Fatalf("GenerateFallbackImage: %v", err)
|
|
}
|
|
|
|
if len(pngBytes) < 1000 {
|
|
t.Fatalf("PNG too small: %d bytes", len(pngBytes))
|
|
}
|
|
|
|
if os.Getenv("OG_WRITE_TEST") != "" {
|
|
_ = os.WriteFile("/tmp/og-test-fallback.png", pngBytes, 0o644)
|
|
t.Logf("wrote /tmp/og-test-fallback.png (%d bytes)", len(pngBytes))
|
|
}
|
|
}
|