package fault

import (
	"os"
	"testing"
)

// TestMain controls whether fault injection tests run
// These tests require toxiproxy and are intended for nightly CI only
func TestMain(m *testing.M) {
	// Check if fault injection tests should run
	if os.Getenv("FETCH_ML_FAULT_INJECTION") != "1" {
		// Skip all fault tests silently
		os.Exit(0)
	}
	os.Exit(m.Run())
}

// TestNVMLUnavailableProvenanceFail verifies that when NVML is unavailable
// and ProvenanceBestEffort=false, the job fails loudly (no silent degradation)
func TestNVMLUnavailableProvenanceFail(t *testing.T) {
	t.Skip("Requires toxiproxy setup for GPU/NVML fault simulation")
}

// TestManifestWritePartialFailure verifies that if manifest write fails midway,
// no partial manifest is left on disk
func TestManifestWritePartialFailure(t *testing.T) {
	t.Skip("Requires toxiproxy or disk fault injection setup")
}

// TestRedisUnavailableQueueBehavior verifies that when Redis is unavailable,
// there is no silent queue item drop
func TestRedisUnavailableQueueBehavior(t *testing.T) {
	t.Skip("Requires toxiproxy for Redis fault simulation")
}

// TestAuditLogUnavailableHaltsJob verifies that if audit log write fails,
// the job halts rather than continuing without audit trail
func TestAuditLogUnavailableHaltsJob(t *testing.T) {
	t.Skip("Requires toxiproxy for audit log fault simulation")
}

// TestConfigHashFailureProvenanceClosed verifies that if config hash computation
// fails in strict mode, the operation fails closed (secure default)
func TestConfigHashFailureProvenanceClosed(t *testing.T) {
	t.Skip("Requires fault injection framework for hash computation failures")
}

// TestDiskFullDuringArtifactScan verifies that when disk is full during
// artifact scanning, an error is returned rather than a partial manifest
func TestDiskFullDuringArtifactScan(t *testing.T) {
	t.Skip("Requires disk space fault injection or container limits")
}
