Add unit tests for Reticulum-Go packages including reticulum, storage, announce, channel, destination, identity, resource, and transport, ensuring comprehensive coverage of functionality.
Some checks failed
Go Build Multi-Platform / build (amd64, freebsd) (push) Successful in 51s
Go Build Multi-Platform / build (amd64, windows) (push) Successful in 49s
Go Build Multi-Platform / build (arm, linux) (push) Successful in 58s
Go Build Multi-Platform / build (arm64, darwin) (push) Successful in 57s
Go Build Multi-Platform / build (arm64, windows) (push) Failing after 49s
Go Test Multi-Platform / Test (ubuntu-latest, arm64) (push) Successful in 53s
Run Gosec / tests (push) Successful in 1m25s
Go Revive Lint / lint (push) Successful in 48s
Go Test Multi-Platform / Test (ubuntu-latest, amd64) (push) Successful in 1m39s
Go Build Multi-Platform / build (arm64, linux) (push) Failing after 4m59s
Go Build Multi-Platform / build (amd64, linux) (push) Successful in 9m39s
Go Build Multi-Platform / build (arm64, freebsd) (push) Successful in 9m33s
Go Build Multi-Platform / build (arm, windows) (push) Successful in 9m35s
Go Build Multi-Platform / build (arm, freebsd) (push) Successful in 9m37s
Go Build Multi-Platform / build (amd64, darwin) (push) Successful in 9m42s
Go Build Multi-Platform / Create Release (push) Has been skipped
Some checks failed
Go Build Multi-Platform / build (amd64, freebsd) (push) Successful in 51s
Go Build Multi-Platform / build (amd64, windows) (push) Successful in 49s
Go Build Multi-Platform / build (arm, linux) (push) Successful in 58s
Go Build Multi-Platform / build (arm64, darwin) (push) Successful in 57s
Go Build Multi-Platform / build (arm64, windows) (push) Failing after 49s
Go Test Multi-Platform / Test (ubuntu-latest, arm64) (push) Successful in 53s
Run Gosec / tests (push) Successful in 1m25s
Go Revive Lint / lint (push) Successful in 48s
Go Test Multi-Platform / Test (ubuntu-latest, amd64) (push) Successful in 1m39s
Go Build Multi-Platform / build (arm64, linux) (push) Failing after 4m59s
Go Build Multi-Platform / build (amd64, linux) (push) Successful in 9m39s
Go Build Multi-Platform / build (arm64, freebsd) (push) Successful in 9m33s
Go Build Multi-Platform / build (arm, windows) (push) Successful in 9m35s
Go Build Multi-Platform / build (arm, freebsd) (push) Successful in 9m37s
Go Build Multi-Platform / build (amd64, darwin) (push) Successful in 9m42s
Go Build Multi-Platform / Create Release (push) Has been skipped
This commit is contained in:
61
cmd/reticulum-go/reticulum_test.go
Normal file
61
cmd/reticulum-go/reticulum_test.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"git.quad4.io/Networks/Reticulum-Go/internal/config"
|
||||
"git.quad4.io/Networks/Reticulum-Go/pkg/common"
|
||||
)
|
||||
|
||||
func TestNewReticulum(t *testing.T) {
|
||||
// Set up a temporary home directory for testing
|
||||
tmpDir := t.TempDir()
|
||||
originalHome := os.Getenv("HOME")
|
||||
os.Setenv("HOME", tmpDir)
|
||||
defer os.Setenv("HOME", originalHome)
|
||||
|
||||
cfg := config.DefaultConfig()
|
||||
// Disable interfaces for simple test
|
||||
cfg.Interfaces = make(map[string]*common.InterfaceConfig)
|
||||
|
||||
r, err := NewReticulum(cfg)
|
||||
if err != nil {
|
||||
t.Fatalf("NewReticulum failed: %v", err)
|
||||
}
|
||||
if r == nil {
|
||||
t.Fatal("NewReticulum returned nil")
|
||||
}
|
||||
|
||||
if r.identity == nil {
|
||||
t.Error("Reticulum identity should not be nil")
|
||||
}
|
||||
if r.destination == nil {
|
||||
t.Error("Reticulum destination should not be nil")
|
||||
}
|
||||
|
||||
// Verify directories were created
|
||||
basePath := filepath.Join(tmpDir, ".reticulum-go")
|
||||
if _, err := os.Stat(basePath); os.IsNotExist(err) {
|
||||
t.Error("Base directory not created")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNodeAppData(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
os.Setenv("HOME", tmpDir)
|
||||
|
||||
r := &Reticulum{
|
||||
nodeEnabled: true,
|
||||
maxTransferSize: 500,
|
||||
}
|
||||
|
||||
data := r.createNodeAppData()
|
||||
if len(data) == 0 {
|
||||
t.Error("createNodeAppData returned empty data")
|
||||
}
|
||||
if data[0] != 0x93 {
|
||||
t.Errorf("Expected array header 0x93, got 0x%x", data[0])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user