network/pkg/serverless/registry_test.go
anonpenguin23 4ee76588ed feat: refactor API gateway and CLI utilities for improved functionality
- Updated the API gateway documentation to reflect changes in architecture and functionality, emphasizing its role as a multi-functional entry point for decentralized services.
- Refactored CLI commands to utilize utility functions for better code organization and maintainability.
- Introduced new utility functions for handling peer normalization, service management, and port validation, enhancing the overall CLI experience.
- Added a new production installation script to streamline the setup process for users, including detailed dry-run summaries for better visibility.
- Enhanced validation mechanisms for configuration files and swarm keys, ensuring robust error handling and user feedback during setup.
2025-12-31 10:48:15 +02:00

42 lines
975 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))
}
}