add stable media support and sync skillhub UI
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@@ -21,6 +22,9 @@ func TestArtifactUploadCreatesReadableArtifactForSourceArtifactID(t *testing.T)
|
||||
if err != nil {
|
||||
t.Fatalf("NewWithConfig: %v", err)
|
||||
}
|
||||
srv := httptest.NewServer(server.Handler())
|
||||
defer srv.Close()
|
||||
server.cfg.PublicBaseURL = srv.URL
|
||||
|
||||
sessionToken, _, ok, err := server.store.createSession("sk-upload-user")
|
||||
if err != nil {
|
||||
@@ -80,9 +84,34 @@ func TestArtifactUploadCreatesReadableArtifactForSourceArtifactID(t *testing.T)
|
||||
if envelope.Data.ID == "" {
|
||||
t.Fatalf("expected artifact id, got %#v", envelope.Data)
|
||||
}
|
||||
if envelope.Data.MediaID == "" {
|
||||
t.Fatalf("expected media id, got %#v", envelope.Data)
|
||||
}
|
||||
if envelope.Data.ContentType != "image/png" {
|
||||
t.Fatalf("expected image/png, got %q", envelope.Data.ContentType)
|
||||
}
|
||||
if envelope.Data.URL == "" {
|
||||
t.Fatalf("expected stable artifact url, got %#v", envelope.Data)
|
||||
}
|
||||
if envelope.Data.StorageStatus != "ready" {
|
||||
t.Fatalf("expected storage status ready, got %#v", envelope.Data.StorageStatus)
|
||||
}
|
||||
|
||||
contentResp, err := http.Get(envelope.Data.URL)
|
||||
if err != nil {
|
||||
t.Fatalf("GET media content: %v", err)
|
||||
}
|
||||
defer contentResp.Body.Close()
|
||||
if contentResp.StatusCode != http.StatusOK {
|
||||
t.Fatalf("expected media content 200, got %d", contentResp.StatusCode)
|
||||
}
|
||||
streamed, err := io.ReadAll(contentResp.Body)
|
||||
if err != nil {
|
||||
t.Fatalf("read media content: %v", err)
|
||||
}
|
||||
if !bytes.Equal(streamed, imageBytes) {
|
||||
t.Fatal("expected stable media url to serve uploaded bytes")
|
||||
}
|
||||
|
||||
editRef, err := server.resolveImageToImageReference(context.Background(), &job{
|
||||
UserID: current.User.ID,
|
||||
|
||||
Reference in New Issue
Block a user