ensure alt_advancement can build
This commit is contained in:
parent
4129584165
commit
1bf001834b
100
internal/alt_advancement/aa_test.go
Normal file
100
internal/alt_advancement/aa_test.go
Normal file
@ -0,0 +1,100 @@
|
||||
package alt_advancement
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestPackageBuild(t *testing.T) {
|
||||
// Basic test to verify the package builds
|
||||
config := AAManagerConfig{
|
||||
UpdateInterval: time.Second * 30,
|
||||
SaveInterval: time.Minute * 5,
|
||||
AutoSave: true,
|
||||
}
|
||||
|
||||
manager := NewAAManager(config)
|
||||
if manager == nil {
|
||||
t.Fatal("NewAAManager returned nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAAManagerBasics(t *testing.T) {
|
||||
config := AAManagerConfig{
|
||||
UpdateInterval: time.Second * 30,
|
||||
SaveInterval: time.Minute * 5,
|
||||
AutoSave: true,
|
||||
}
|
||||
|
||||
manager := NewAAManager(config)
|
||||
|
||||
// Test configuration
|
||||
currentConfig := manager.GetConfig()
|
||||
if currentConfig.UpdateInterval != config.UpdateInterval {
|
||||
t.Error("Expected config to match")
|
||||
}
|
||||
|
||||
// Test stats
|
||||
stats := manager.GetSystemStats()
|
||||
if stats == nil {
|
||||
t.Error("Expected valid stats")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMasterAAList(t *testing.T) {
|
||||
masterList := NewMasterAAList()
|
||||
if masterList == nil {
|
||||
t.Fatal("NewMasterAAList returned nil")
|
||||
}
|
||||
|
||||
// Test size with empty list
|
||||
if masterList.Size() != 0 {
|
||||
t.Error("Expected empty list to have size 0")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMasterAANodeList(t *testing.T) {
|
||||
nodeList := NewMasterAANodeList()
|
||||
if nodeList == nil {
|
||||
t.Fatal("NewMasterAANodeList returned nil")
|
||||
}
|
||||
|
||||
// Test size with empty list
|
||||
if nodeList.Size() != 0 {
|
||||
t.Error("Expected empty node list to have size 0")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAATemplate(t *testing.T) {
|
||||
template := NewAATemplate(1, "Test Template")
|
||||
if template == nil {
|
||||
t.Fatal("NewAATemplate returned nil")
|
||||
}
|
||||
|
||||
if template.TemplateID != 1 {
|
||||
t.Error("Expected template ID to be 1")
|
||||
}
|
||||
|
||||
if template.Name != "Test Template" {
|
||||
t.Error("Expected template name to be 'Test Template'")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAAPlayerState(t *testing.T) {
|
||||
playerState := NewAAPlayerState(123)
|
||||
if playerState == nil {
|
||||
t.Fatal("NewAAPlayerState returned nil")
|
||||
}
|
||||
|
||||
if playerState.CharacterID != 123 {
|
||||
t.Error("Expected character ID to be 123")
|
||||
}
|
||||
|
||||
if playerState.AAProgress == nil {
|
||||
t.Error("Expected AAProgress to be initialized")
|
||||
}
|
||||
|
||||
if playerState.Templates == nil {
|
||||
t.Error("Expected Templates to be initialized")
|
||||
}
|
||||
}
|
@ -653,7 +653,7 @@ func (am *AAManager) saveAllPlayerStates() {
|
||||
am.statesMutex.RLock()
|
||||
defer am.statesMutex.RUnlock()
|
||||
|
||||
for characterID, playerState := range am.playerStates {
|
||||
for _, playerState := range am.playerStates {
|
||||
if playerState.needsSync {
|
||||
if err := am.database.SavePlayerAA(playerState); err != nil {
|
||||
am.updateErrorStats("database_errors")
|
||||
|
@ -207,6 +207,12 @@ type AAManager struct {
|
||||
eventHandlers []AAEventHandler `json:"-"`
|
||||
eventMutex sync.RWMutex `json:"-"`
|
||||
|
||||
// Validation and notification interfaces
|
||||
validator AAValidator `json:"-"`
|
||||
notifier AANotifier `json:"-"`
|
||||
statistics AAStatistics `json:"-"`
|
||||
cache AACache `json:"-"`
|
||||
|
||||
// Statistics
|
||||
stats AAManagerStats `json:"stats"`
|
||||
statsMutex sync.RWMutex `json:"-"`
|
||||
|
Loading…
x
Reference in New Issue
Block a user