mirror of
https://github.com/DeBrosOfficial/network.git
synced 2026-01-30 15:43:03 +00:00
- Updated the serverless functions table schema to remove the version constraint for uniqueness, allowing for more flexible function definitions. - Enhanced the serverless engine to support HTTP fetch functionality, enabling external API calls from serverless functions. - Implemented logging capabilities for function invocations, capturing detailed logs for better debugging and monitoring. - Improved the authentication middleware to handle public endpoints more effectively, ensuring seamless access to serverless functions. - Added new configuration options for serverless functions, including memory limits, timeout settings, and retry parameters, to optimize performance and reliability.
41 lines
972 B
Go
41 lines
972 B
Go
package serverless
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func TestRegistry_RegisterAndGet(t *testing.T) {
|
|
db := NewMockRQLite()
|
|
ipfs := NewMockIPFSClient()
|
|
logger := zap.NewNop()
|
|
|
|
registry := NewRegistry(db, ipfs, RegistryConfig{IPFSAPIURL: "http://localhost:5001"}, logger)
|
|
|
|
ctx := context.Background()
|
|
fnDef := &FunctionDefinition{
|
|
Name: "test-func",
|
|
Namespace: "test-ns",
|
|
IsPublic: true,
|
|
}
|
|
wasmBytes := []byte("mock wasm")
|
|
|
|
_, err := registry.Register(ctx, fnDef, wasmBytes)
|
|
if err != nil {
|
|
t.Fatalf("Register failed: %v", err)
|
|
}
|
|
|
|
// Since MockRQLite doesn't fully implement Query scanning yet,
|
|
// we won't be able to test Get() effectively without more work.
|
|
// But we can check if wasm was uploaded.
|
|
wasm, err := registry.GetWASMBytes(ctx, "cid-test-func.wasm")
|
|
if err != nil {
|
|
t.Fatalf("GetWASMBytes failed: %v", err)
|
|
}
|
|
if string(wasm) != "mock wasm" {
|
|
t.Errorf("expected 'mock wasm', got %q", string(wasm))
|
|
}
|
|
}
|