All checks were successful
Reply to a message containing a link with !gallerydl (or send it with a link inline) to download the media via the gallery-dl CLI and have the files posted back as a reply. Restricted to an allowed_users allowlist (comma-separated, per-channel/global config); no one is allowed by default. - Add media support to the platform layer: model.Message.Files, ActionSendMedia, and Platform.SendMedia. Telegram uploads via multipart (sendPhoto/sendVideo/sendDocument, 50MB cap); Slack returns unsupported for now. - Add internal/shell (os/exec wrapper) and internal/urlutil (URL extraction) helpers with tests. - Dispatch ActionSendMedia in app and clean up the temp download dir. - Admin config UI for allowed_users / gallery_dl_path; docs entry. - Containerfile: base on alpine and install gallery-dl + ffmpeg (was scratch); release workflow sets up QEMU + Buildx for cross-arch image builds.
45 lines
986 B
Go
45 lines
986 B
Go
package shell
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestRun(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
out, err := Run(ctx, "echo", "hello")
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
if strings.TrimSpace(out) != "hello" {
|
|
t.Errorf("expected output %q, got %q", "hello", strings.TrimSpace(out))
|
|
}
|
|
}
|
|
|
|
func TestRunNonZeroExit(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
if _, err := Run(ctx, "false"); err == nil {
|
|
t.Error("expected error for non-zero exit, got nil")
|
|
}
|
|
}
|
|
|
|
func TestRunMissingBinary(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
if _, err := Run(ctx, "this-binary-should-not-exist-butterrobot"); err == nil {
|
|
t.Error("expected error for missing binary, got nil")
|
|
}
|
|
}
|
|
|
|
func TestRunTimeout(t *testing.T) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond)
|
|
defer cancel()
|
|
|
|
if _, err := Run(ctx, "sleep", "5"); err == nil {
|
|
t.Error("expected error when context times out, got nil")
|
|
}
|
|
}
|