File tree Expand file tree Collapse file tree 2 files changed +19
-15
lines changed
frontend-modern/src/pages/__tests__ Expand file tree Collapse file tree 2 files changed +19
-15
lines changed Original file line number Diff line number Diff line change @@ -12,11 +12,11 @@ import {
1212 pathForTab ,
1313 tabFromPath ,
1414} from '../Alerts' ;
15+ import type { RawOverrideConfig } from '@/types/alerts' ;
1516
1617describe ( 'normalizeMetricDelayMap' , ( ) => {
1718 it ( 'returns empty object when input is nullish' , ( ) => {
1819 expect ( normalizeMetricDelayMap ( undefined ) ) . toEqual ( { } ) ;
19- // @ts -expect-error - testing runtime null handling
2020 expect ( normalizeMetricDelayMap ( null ) ) . toEqual ( { } ) ;
2121 } ) ;
2222
@@ -139,17 +139,19 @@ describe('threshold helper utilities', () => {
139139 it ( 'extracts trigger values and ignores non-threshold keys' , ( ) => {
140140 const result = extractTriggerValues ( {
141141 cpu : { trigger : 80 , clear : 70 } ,
142- memory : 85 ,
142+ memory : { trigger : 85 , clear : 75 } ,
143143 disabled : true ,
144144 poweredOffSeverity : 'warning' ,
145- networkIn : false ,
145+ customFlag : true ,
146+ customLegacy : 42 ,
146147 label : 'ignored' ,
147- } ) ;
148+ } as RawOverrideConfig ) ;
148149
149150 expect ( result ) . toEqual ( {
150151 cpu : 80 ,
151152 memory : 85 ,
152- networkIn : 0 ,
153+ customFlag : 0 ,
154+ customLegacy : 42 ,
153155 } ) ;
154156 } ) ;
155157
Original file line number Diff line number Diff line change @@ -120,29 +120,31 @@ func disableMockMode() {
120120
121121func startUpdateLoopLocked () {
122122 stopUpdateLoopLocked ()
123- stopUpdatesCh = make (chan struct {})
124- updateTicker = time .NewTicker (updateInterval )
123+ stopCh := make (chan struct {})
124+ ticker := time .NewTicker (updateInterval )
125+ stopUpdatesCh = stopCh
126+ updateTicker = ticker
125127
126- go func () {
128+ go func (stop <- chan struct {}, tick * time. Ticker ) {
127129 for {
128130 select {
129- case <- updateTicker .C :
131+ case <- tick .C :
130132 cfg := GetConfig ()
131133 updateMetrics (cfg )
132- case <- stopUpdatesCh :
134+ case <- stop :
133135 return
134136 }
135137 }
136- }()
138+ }(stopCh , ticker )
137139}
138140
139141func stopUpdateLoopLocked () {
140- if updateTicker != nil {
141- updateTicker .Stop ()
142+ if ticker := updateTicker ; ticker != nil {
143+ ticker .Stop ()
142144 updateTicker = nil
143145 }
144- if stopUpdatesCh != nil {
145- close (stopUpdatesCh )
146+ if ch := stopUpdatesCh ; ch != nil {
147+ close (ch )
146148 stopUpdatesCh = nil
147149 }
148150}
You can’t perform that action at this time.
0 commit comments