Files
truewhile b0fe40142a Rebrand MMTL to MeBox (name, logo, Docker image) (#17)
* Rebrand MMTL to MeBox across codebase and assets

Rename the project display name, Go module path, environment variable
prefix (MEBOX_*), Docker image references, and UI branding from MMTL/mmtl
to MeBox/mebox. Replace logo assets with the new MeBox icon and keep
legacy SQLite migration support for existing mmtl.db deployments.

Co-authored-by: truewhile <truewhile@users.noreply.github.com>

* Fix logo icons: use cube-only crop without truncated text

Previous icon generation cropped too much of the source image, including
partial MeBox wordmark text that was cut off in square icon containers.
Regenerate logo-64/192/512, favicon, and SVG from cube-only region.

Co-authored-by: truewhile <truewhile@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: truewhile <truewhile@users.noreply.github.com>
2026-09-02 16:26:28 +08:00

58 lines
1.5 KiB
Go

package repository
import (
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"github.com/truewhile/MeBox/internal/config"
)
func TestOpenSearchMediaBackendSearchesIDs(t *testing.T) {
var gotPath string
upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
gotPath = r.URL.Path
if r.Method != http.MethodPost {
t.Fatalf("method = %s, want POST", r.Method)
}
var body map[string]any
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
t.Fatal(err)
}
if body["from"].(float64) != 5 || body["size"].(float64) != 10 {
t.Fatalf("paging body = %#v", body)
}
_ = json.NewEncoder(w).Encode(map[string]any{
"hits": map[string]any{
"total": map[string]any{"value": 2},
"hits": []any{
map[string]any{"_id": "m-1", "_source": map[string]any{"id": "m-1"}},
map[string]any{"_id": "m-2", "_source": map[string]any{"id": "m-2"}},
},
},
})
}))
defer upstream.Close()
backend := NewOpenSearchMediaBackend(config.SearchConfig{
Backend: "opensearch",
OpenSearchURL: upstream.URL,
Index: "media-test",
})
ids, total, err := backend.SearchMediaIDs(t.Context(), "流浪地球", 5, 10, MediaQueryFilter{
IncludeNSFW: false,
AllowedLibraryIDs: []string{"lib-1"},
HiddenLibraryIDs: []string{"adult"},
})
if err != nil {
t.Fatal(err)
}
if gotPath != "/media-test/_search" {
t.Fatalf("path = %q", gotPath)
}
if total != 2 || len(ids) != 2 || ids[0] != "m-1" || ids[1] != "m-2" {
t.Fatalf("ids=%#v total=%d", ids, total)
}
}