ax(batch): apply Good/Bad/Ugly test naming convention across all packages
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run

Renames test functions to follow TestFilename_Function_{Good,Bad,Ugly}
convention per AX test naming rules. Covers profile_manager_test.go
(11 tests), events_test.go (9 tests), container_test.go (8 tests),
logger_test.go (9 tests), database_test.go (10 tests).

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 18:20:32 +01:00
parent 3673757d2a
commit 14cf520778
No known key found for this signature in database
GPG key ID: AF404715446AEB41
5 changed files with 50 additions and 50 deletions

View file

@ -51,7 +51,7 @@ func TestDatabase_Initialize_Bad(t *testing.T) {
}
}
func TestClose(t *testing.T) {
func TestDatabase_Close_Good(t *testing.T) {
cleanup := setupTestDB(t)
defer cleanup()
@ -61,7 +61,7 @@ func TestClose(t *testing.T) {
}
}
func TestHashrateStorage(t *testing.T) {
func TestDatabase_HashrateStorage_Good(t *testing.T) {
cleanup := setupTestDB(t)
defer cleanup()
@ -93,7 +93,7 @@ func TestHashrateStorage(t *testing.T) {
}
}
func TestGetHashrateStats(t *testing.T) {
func TestDatabase_GetHashrateStats_Good(t *testing.T) {
cleanup := setupTestDB(t)
defer cleanup()
@ -137,7 +137,7 @@ func TestGetHashrateStats(t *testing.T) {
}
}
func TestDefaultConfig(t *testing.T) {
func TestDatabase_DefaultConfig_Good(t *testing.T) {
config := defaultConfig()
if !config.Enabled {
@ -149,7 +149,7 @@ func TestDefaultConfig(t *testing.T) {
}
}
func TestCleanupRetention(t *testing.T) {
func TestDatabase_CleanupRetention_Good(t *testing.T) {
cleanup := setupTestDB(t)
defer cleanup()
@ -216,7 +216,7 @@ func TestCleanupRetention(t *testing.T) {
}
}
func TestGetHashrateHistoryTimeRange(t *testing.T) {
func TestDatabase_GetHashrateHistoryTimeRange_Good(t *testing.T) {
cleanup := setupTestDB(t)
defer cleanup()
@ -269,7 +269,7 @@ func TestGetHashrateHistoryTimeRange(t *testing.T) {
}
}
func TestMultipleMinerStats(t *testing.T) {
func TestDatabase_MultipleMinerStats_Good(t *testing.T) {
cleanup := setupTestDB(t)
defer cleanup()
@ -332,7 +332,7 @@ func TestMultipleMinerStats(t *testing.T) {
}
}
func TestIsInitialized(t *testing.T) {
func TestDatabase_IsInitialized_Good(t *testing.T) {
// Before initialization
Close() // Ensure clean state
if isInitialized() {
@ -354,7 +354,7 @@ func TestIsInitialized(t *testing.T) {
}
}
func TestSchemaCreation(t *testing.T) {
func TestDatabase_SchemaCreation_Good(t *testing.T) {
cleanup := setupTestDB(t)
defer cleanup()
@ -388,7 +388,7 @@ func TestSchemaCreation(t *testing.T) {
}
}
func TestReInitializeExistingDB(t *testing.T) {
func TestDatabase_ReInitializeExistingDB_Good(t *testing.T) {
tmpDir := t.TempDir()
dbPath := filepath.Join(tmpDir, "reinit_test.db")
@ -442,7 +442,7 @@ func TestReInitializeExistingDB(t *testing.T) {
}
}
func TestConcurrentDatabaseAccess(t *testing.T) {
func TestDatabase_ConcurrentAccess_Ugly(t *testing.T) {
cleanup := setupTestDB(t)
defer cleanup()

View file

@ -65,7 +65,7 @@ func TestLogger_Log_Ugly(t *testing.T) {
}
}
func TestLoggerWithFields(t *testing.T) {
func TestLogger_WithFields_Good(t *testing.T) {
var buf bytes.Buffer
logger := New(Config{
Output: &buf,
@ -83,7 +83,7 @@ func TestLoggerWithFields(t *testing.T) {
}
}
func TestLoggerWithComponent(t *testing.T) {
func TestLogger_WithComponent_Good(t *testing.T) {
var buf bytes.Buffer
logger := New(Config{
Output: &buf,
@ -99,7 +99,7 @@ func TestLoggerWithComponent(t *testing.T) {
}
}
func TestLoggerDerivedComponent(t *testing.T) {
func TestLogger_DerivedComponent_Good(t *testing.T) {
var buf bytes.Buffer
parent := New(Config{
Output: &buf,
@ -115,7 +115,7 @@ func TestLoggerDerivedComponent(t *testing.T) {
}
}
func TestLoggerFormatted(t *testing.T) {
func TestLogger_Formatted_Good(t *testing.T) {
var buf bytes.Buffer
logger := New(Config{
Output: &buf,
@ -130,7 +130,7 @@ func TestLoggerFormatted(t *testing.T) {
}
}
func TestSetLevel(t *testing.T) {
func TestLogger_SetLevel_Good(t *testing.T) {
var buf bytes.Buffer
logger := New(Config{
Output: &buf,
@ -156,7 +156,7 @@ func TestSetLevel(t *testing.T) {
}
}
func TestParseLevel(t *testing.T) {
func TestLogger_ParseLevel_Good(t *testing.T) {
tests := []struct {
input string
expected Level
@ -189,7 +189,7 @@ func TestParseLevel(t *testing.T) {
}
}
func TestGlobalLogger(t *testing.T) {
func TestLogger_GlobalLogger_Good(t *testing.T) {
var buf bytes.Buffer
logger := New(Config{
Output: &buf,
@ -214,7 +214,7 @@ func TestGlobalLogger(t *testing.T) {
SetGlobal(New(DefaultConfig()))
}
func TestLevelString(t *testing.T) {
func TestLogger_LevelString_Good(t *testing.T) {
tests := []struct {
level Level
expected string
@ -233,7 +233,7 @@ func TestLevelString(t *testing.T) {
}
}
func TestMergeFields(t *testing.T) {
func TestLogger_MergeFields_Good(t *testing.T) {
// Empty fields
result := mergeFields(nil)
if result != nil {

View file

@ -53,7 +53,7 @@ func TestContainer_DefaultContainerConfig_Good(t *testing.T) {
}
}
func TestContainer_Initialize(t *testing.T) {
func TestContainer_Initialize_Good(t *testing.T) {
cleanup := setupContainerTestEnv(t)
defer cleanup()
@ -96,7 +96,7 @@ func TestContainer_Initialize(t *testing.T) {
}
}
func TestContainer_InitializeTwice(t *testing.T) {
func TestContainer_InitializeTwice_Bad(t *testing.T) {
cleanup := setupContainerTestEnv(t)
defer cleanup()
@ -119,7 +119,7 @@ func TestContainer_InitializeTwice(t *testing.T) {
container.Shutdown(ctx)
}
func TestContainer_DatabaseDisabled(t *testing.T) {
func TestContainer_DatabaseDisabled_Good(t *testing.T) {
cleanup := setupContainerTestEnv(t)
defer cleanup()
@ -152,7 +152,7 @@ func TestContainer_DatabaseDisabled(t *testing.T) {
container.Shutdown(ctx)
}
func TestContainer_SetHashrateStore(t *testing.T) {
func TestContainer_SetHashrateStore_Good(t *testing.T) {
cleanup := setupContainerTestEnv(t)
defer cleanup()
@ -178,7 +178,7 @@ func TestContainer_SetHashrateStore(t *testing.T) {
container.Shutdown(ctx)
}
func TestContainer_StartWithoutInitialize(t *testing.T) {
func TestContainer_StartWithoutInitialize_Bad(t *testing.T) {
config := DefaultContainerConfig()
container := NewContainer(config)
ctx := context.Background()
@ -188,7 +188,7 @@ func TestContainer_StartWithoutInitialize(t *testing.T) {
}
}
func TestContainer_ShutdownWithoutInitialize(t *testing.T) {
func TestContainer_ShutdownWithoutInitialize_Good(t *testing.T) {
config := DefaultContainerConfig()
container := NewContainer(config)
ctx := context.Background()
@ -199,7 +199,7 @@ func TestContainer_ShutdownWithoutInitialize(t *testing.T) {
}
}
func TestContainer_ShutdownChannel(t *testing.T) {
func TestContainer_ShutdownChannel_Good(t *testing.T) {
cleanup := setupContainerTestEnv(t)
defer cleanup()
@ -237,7 +237,7 @@ func TestContainer_ShutdownChannel(t *testing.T) {
}
}
func TestContainer_InitializeWithCancelledContext(t *testing.T) {
func TestContainer_InitializeWithCancelledContext_Ugly(t *testing.T) {
cleanup := setupContainerTestEnv(t)
defer cleanup()
@ -264,7 +264,7 @@ func TestContainer_InitializeWithCancelledContext(t *testing.T) {
}
}
func TestContainer_ShutdownWithTimeout(t *testing.T) {
func TestContainer_ShutdownWithTimeout_Ugly(t *testing.T) {
cleanup := setupContainerTestEnv(t)
defer cleanup()
@ -289,7 +289,7 @@ func TestContainer_ShutdownWithTimeout(t *testing.T) {
}
}
func TestContainer_DoubleShutdown(t *testing.T) {
func TestContainer_DoubleShutdown_Ugly(t *testing.T) {
cleanup := setupContainerTestEnv(t)
defer cleanup()

View file

@ -9,7 +9,7 @@ import (
"github.com/gorilla/websocket"
)
func TestNewEventHub(t *testing.T) {
func TestEvents_NewEventHub_Good(t *testing.T) {
hub := NewEventHub()
if hub == nil {
t.Fatal("NewEventHub returned nil")
@ -24,7 +24,7 @@ func TestNewEventHub(t *testing.T) {
}
}
func TestNewEventHubWithOptions(t *testing.T) {
func TestEvents_NewEventHubWithOptions_Good(t *testing.T) {
hub := NewEventHubWithOptions(50)
if hub.maxConnections != 50 {
t.Errorf("Expected maxConnections 50, got %d", hub.maxConnections)
@ -42,7 +42,7 @@ func TestNewEventHubWithOptions(t *testing.T) {
}
}
func TestEventHubBroadcast(t *testing.T) {
func TestEvents_Broadcast_Good(t *testing.T) {
hub := NewEventHub()
go hub.Run()
defer hub.Stop()
@ -69,7 +69,7 @@ func TestEventHubBroadcast(t *testing.T) {
}
}
func TestEventHubClientCount(t *testing.T) {
func TestEvents_ClientCount_Good(t *testing.T) {
hub := NewEventHub()
go hub.Run()
defer hub.Stop()
@ -80,7 +80,7 @@ func TestEventHubClientCount(t *testing.T) {
}
}
func TestEventHubStop(t *testing.T) {
func TestEvents_Stop_Good(t *testing.T) {
hub := NewEventHub()
go hub.Run()
@ -97,7 +97,7 @@ func TestEventHubStop(t *testing.T) {
time.Sleep(50 * time.Millisecond)
}
func TestNewEvent(t *testing.T) {
func TestEvents_NewEvent_Good(t *testing.T) {
data := MinerEventData{Name: "test-miner"}
event := NewEvent(EventMinerStarted, data)
@ -118,7 +118,7 @@ func TestNewEvent(t *testing.T) {
}
}
func TestEventJSON(t *testing.T) {
func TestEvents_JSON_Good(t *testing.T) {
event := Event{
Type: EventMinerStats,
Timestamp: time.Now(),
@ -146,7 +146,7 @@ func TestEventJSON(t *testing.T) {
}
}
func TestSetStateProvider(t *testing.T) {
func TestEvents_SetStateProvider_Good(t *testing.T) {
hub := NewEventHub()
go hub.Run()
defer hub.Stop()
@ -180,7 +180,7 @@ type MockWebSocketConn struct {
mu sync.Mutex
}
func TestEventTypes(t *testing.T) {
func TestEvents_EventTypes_Good(t *testing.T) {
types := []EventType{
EventMinerStarting,
EventMinerStarted,

View file

@ -29,7 +29,7 @@ func setupTestProfileManager(t *testing.T) (*ProfileManager, func()) {
return profileManager, cleanup
}
func TestProfileManagerCreate(t *testing.T) {
func TestProfileManager_Create_Good(t *testing.T) {
profileManager, cleanup := setupTestProfileManager(t)
defer cleanup()
@ -63,7 +63,7 @@ func TestProfileManagerCreate(t *testing.T) {
}
}
func TestProfileManagerGet(t *testing.T) {
func TestProfileManager_Get_Good(t *testing.T) {
profileManager, cleanup := setupTestProfileManager(t)
defer cleanup()
@ -90,7 +90,7 @@ func TestProfileManagerGet(t *testing.T) {
}
}
func TestProfileManagerGetAll(t *testing.T) {
func TestProfileManager_GetAll_Good(t *testing.T) {
profileManager, cleanup := setupTestProfileManager(t)
defer cleanup()
@ -114,7 +114,7 @@ func TestProfileManagerGetAll(t *testing.T) {
}
}
func TestProfileManagerUpdate(t *testing.T) {
func TestProfileManager_Update_Good(t *testing.T) {
profileManager, cleanup := setupTestProfileManager(t)
defer cleanup()
@ -149,7 +149,7 @@ func TestProfileManagerUpdate(t *testing.T) {
}
}
func TestProfileManagerDelete(t *testing.T) {
func TestProfileManager_Delete_Good(t *testing.T) {
profileManager, cleanup := setupTestProfileManager(t)
defer cleanup()
@ -178,7 +178,7 @@ func TestProfileManagerDelete(t *testing.T) {
}
}
func TestProfileManagerPersistence(t *testing.T) {
func TestProfileManager_Persistence_Good(t *testing.T) {
tmpDir, err := os.MkdirTemp("", "profile-persist-test")
if err != nil {
t.Fatalf("failed to create temp dir: %v", err)
@ -224,7 +224,7 @@ func TestProfileManagerPersistence(t *testing.T) {
}
}
func TestProfileManagerConcurrency(t *testing.T) {
func TestProfileManager_Concurrency_Ugly(t *testing.T) {
profileManager, cleanup := setupTestProfileManager(t)
defer cleanup()
@ -260,7 +260,7 @@ func TestProfileManagerConcurrency(t *testing.T) {
waitGroup.Wait()
}
func TestProfileManagerInvalidJSON(t *testing.T) {
func TestProfileManager_InvalidJSON_Bad(t *testing.T) {
tmpDir, err := os.MkdirTemp("", "profile-invalid-test")
if err != nil {
t.Fatalf("failed to create temp dir: %v", err)
@ -286,7 +286,7 @@ func TestProfileManagerInvalidJSON(t *testing.T) {
}
}
func TestProfileManagerFileNotFound(t *testing.T) {
func TestProfileManager_FileNotFound_Bad(t *testing.T) {
profileManager := &ProfileManager{
profiles: make(map[string]*MiningProfile),
configPath: "/non/existent/path/profiles.json",
@ -302,7 +302,7 @@ func TestProfileManagerFileNotFound(t *testing.T) {
}
}
func TestProfileManagerCreateRollback(t *testing.T) {
func TestProfileManager_CreateRollback_Ugly(t *testing.T) {
profileManager := &ProfileManager{
profiles: make(map[string]*MiningProfile),
configPath: "/invalid/path/that/cannot/be/written/profiles.json",
@ -325,7 +325,7 @@ func TestProfileManagerCreateRollback(t *testing.T) {
}
}
func TestProfileManagerConfigWithData(t *testing.T) {
func TestProfileManager_ConfigWithData_Good(t *testing.T) {
profileManager, cleanup := setupTestProfileManager(t)
defer cleanup()