//go:build windows package disk import ( "io" "os" "testing" "golang.org/x/sys/windows" "s1d3sw1ped/steamcache2/steamcache/metrics" ) func TestIsNoSpaceError(t *testing.T) { t.Parallel() if isNoSpaceError(nil) { t.Error("nil must not be disk-full") } if isNoSpaceError(io.EOF) { t.Error("EOF must not be disk-full") } if !isNoSpaceError(windows.ERROR_DISK_FULL) { t.Error("ERROR_DISK_FULL should match") } if !isNoSpaceError(windows.ERROR_HANDLE_DISK_FULL) { t.Error("ERROR_HANDLE_DISK_FULL should match") } wrapped := &os.PathError{Op: "write", Path: "x", Err: windows.ERROR_DISK_FULL} if !isNoSpaceError(wrapped) { t.Error("PathError wrapping ERROR_DISK_FULL should match") } } func TestDiskFS_ENOSPCCapacityPressure(t *testing.T) { t.Parallel() d, err := New(t.TempDir(), 1024, nil) if err != nil { t.Fatal(err) } met := metrics.NewMetrics() d.SetMetrics(met) d.recordIfNoSpace(io.EOF) if got := met.GetStats().CapacityPressureEvents; got != 0 { t.Fatalf("non-ENOSPC counted: %d", got) } d.recordIfNoSpace(windows.ERROR_DISK_FULL) if got := met.GetStats().CapacityPressureEvents; got != 1 { t.Fatalf("ERROR_DISK_FULL: CapacityPressureEvents=%d, want 1", got) } if got := met.GetStats().Evictions; got != 0 { t.Fatalf("disk-full must not increment evictions, got %d", got) } }