mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-09-11 06:30:21 +00:00
feat(task): replace built-in task adaptors with a sandboxed JS plugin system (#7076)
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/QuantumNous/new-api/model"
|
||||
"github.com/QuantumNous/new-api/types"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestDisabledTaskArtifactStoreHasNoStorageBehavior(t *testing.T) {
|
||||
store := GetTaskArtifactStore()
|
||||
require.NotNil(t, store)
|
||||
assert.False(t, store.Enabled())
|
||||
|
||||
task := &model.Task{TaskID: "task-disabled-store"}
|
||||
ref, err := store.Resolve(task, "video")
|
||||
require.NoError(t, err)
|
||||
assert.Nil(t, ref)
|
||||
|
||||
ref, err = store.Persist(t.Context(), task, types.TaskArtifact{Key: "video", Type: "video"}, strings.NewReader("content"))
|
||||
assert.Nil(t, ref)
|
||||
assert.ErrorIs(t, err, ErrTaskArtifactStoreDisabled)
|
||||
assert.ErrorIs(t, store.Serve(&gin.Context{}, task, &StoredArtifactRef{Backend: "s3"}), ErrTaskArtifactStoreDisabled)
|
||||
assert.Same(t, store, GetTaskArtifactStore())
|
||||
}
|
||||
|
||||
var _ TaskArtifactStore = disabledArtifactStore{}
|
||||
Reference in New Issue
Block a user