mirror of
https://github.com/DeBrosOfficial/network.git
synced 2026-01-30 05:23:03 +00:00
- 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.
46 lines
1013 B
Go
46 lines
1013 B
Go
package serverless
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func TestHostFunctions_Cache(t *testing.T) {
|
|
db := NewMockRQLite()
|
|
ipfs := NewMockIPFSClient()
|
|
logger := zap.NewNop()
|
|
|
|
// MockOlricClient needs to implement olriclib.Client
|
|
// For now, let's just test other host functions if Olric is hard to mock
|
|
|
|
h := NewHostFunctions(db, nil, ipfs, nil, nil, nil, HostFunctionsConfig{}, logger)
|
|
|
|
ctx := context.Background()
|
|
h.SetInvocationContext(&InvocationContext{
|
|
RequestID: "req-1",
|
|
Namespace: "ns-1",
|
|
})
|
|
|
|
// Test Logging
|
|
h.LogInfo(ctx, "hello world")
|
|
logs := h.GetLogs()
|
|
if len(logs) != 1 || logs[0].Message != "hello world" {
|
|
t.Errorf("unexpected logs: %+v", logs)
|
|
}
|
|
|
|
// Test Storage
|
|
cid, err := h.StoragePut(ctx, []byte("data"))
|
|
if err != nil {
|
|
t.Fatalf("StoragePut failed: %v", err)
|
|
}
|
|
data, err := h.StorageGet(ctx, cid)
|
|
if err != nil {
|
|
t.Fatalf("StorageGet failed: %v", err)
|
|
}
|
|
if string(data) != "data" {
|
|
t.Errorf("expected 'data', got %q", string(data))
|
|
}
|
|
}
|