Module path now matches the GitHub mirror location. All internal imports updated across 35+ files.
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package engines
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
|
)
|
|
|
|
func TestRedditEngine_EmptyQuery(t *testing.T) {
|
|
eng := &RedditEngine{}
|
|
resp, err := eng.Search(context.Background(), contracts.SearchRequest{Query: ""})
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
if len(resp.Results) != 0 {
|
|
t.Errorf("expected 0 results for empty query, got %d", len(resp.Results))
|
|
}
|
|
}
|
|
|
|
func TestRedditEngine_Name(t *testing.T) {
|
|
eng := &RedditEngine{}
|
|
if eng.Name() != "reddit" {
|
|
t.Errorf("expected 'reddit', got %q", eng.Name())
|
|
}
|
|
}
|
|
|
|
func TestRedditEngine_Uninitialized(t *testing.T) {
|
|
eng := &RedditEngine{}
|
|
_, err := eng.Search(context.Background(), contracts.SearchRequest{Query: "test"})
|
|
if err == nil {
|
|
t.Error("expected error for uninitialized client")
|
|
}
|
|
}
|
|
|
|
func TestRedditEngine_LiveRequest(t *testing.T) {
|
|
// Reddit's JSON API returns 403 from non-browser contexts.
|
|
// Skip in CI/sandbox environments.
|
|
t.Skip("reddit API requires browser-like context; test manually")
|
|
_ = context.Background
|
|
_ = http.Client{}
|
|
_ = contracts.SearchRequest{}
|
|
_ = time.Second
|
|
}
|