network/pkg/serverless/registry_test.go
anonpenguin23 4f893e08d1 feat: enhance serverless function management and logging
- 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.
2026-01-02 08:40:28 +02:00

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))
}
}