The importer from t5de-hub's docs/imports.md: says hello to the hub with its key pair, follows the console's config (paused, rate, jobs at a time, IMVU accounts, whose sealed passwords it keeps), claims jobs, finds each product's newest revision on IMVU's CDN, converts it (originals for placeholders, no _contents.json, ProductRating from IMVU's rating), checks it by t5de-api's pack rules and uploads it to the catalog with an import token. Co-Authored-By: Claude Opus 5.5 <[email protected]>
29 lines
889 B
Go
29 lines
889 B
Go
package catalog
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestUploadRefused(t *testing.T) {
|
|
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
if r.Header.Get("Authorization") != "Bearer tok" {
|
|
t.Errorf("authorization %q", r.Header.Get("Authorization"))
|
|
}
|
|
w.WriteHeader(http.StatusBadRequest)
|
|
w.Write([]byte(`{"error":"bad_files","message":"These product files can't be used: index.xml: no ProductRating"}`))
|
|
}))
|
|
defer s.Close()
|
|
_, err := Upload(context.Background(), nil, "test", s.URL, "tok", []byte("zip"))
|
|
var e *Error
|
|
if !errors.As(err, &e) || e.Status != 400 || e.Code != "bad_files" {
|
|
t.Fatalf("got %v", err)
|
|
}
|
|
if e.Error() != "the catalog refused the upload (400 bad_files): These product files can't be used: index.xml: no ProductRating" {
|
|
t.Errorf("message %q", e.Error())
|
|
}
|
|
}
|