MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestSetIfMax

Function TestSetIfMax

base/stats_test.go:123–140  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

121}
122
123func TestSetIfMax(t *testing.T) {
124 sgwStats, err := NewSyncGatewayStats()
125 require.NoError(t, err)
126
127 // Test an integer
128 sgwStats.GlobalStats.ResourceUtilization.ErrorCount.Set(10)
129 sgwStats.GlobalStats.ResourceUtilization.ErrorCount.SetIfMax(100)
130 assert.Equal(t, int64(100), sgwStats.GlobalStats.ResourceUtilizationStats().ErrorCount.Value())
131 sgwStats.GlobalStats.ResourceUtilization.ErrorCount.SetIfMax(50)
132 assert.Equal(t, int64(100), sgwStats.GlobalStats.ResourceUtilizationStats().ErrorCount.Value())
133
134 // Test a float
135 sgwStats.GlobalStats.ResourceUtilization.CpuPercentUtil.Set(10)
136 sgwStats.GlobalStats.ResourceUtilization.CpuPercentUtil.SetIfMax(100)
137 assert.Equal(t, float64(100), sgwStats.GlobalStats.ResourceUtilizationStats().CpuPercentUtil.Value())
138 sgwStats.GlobalStats.ResourceUtilization.CpuPercentUtil.SetIfMax(50)
139 assert.Equal(t, float64(100), sgwStats.GlobalStats.ResourceUtilizationStats().CpuPercentUtil.Value())
140}
141
142func initExpvarBaseEquivalent() *expvar.Map {
143 expvarMap := new(expvar.Map).Init()

Callers

nothing calls this directly

Calls 6

NewSyncGatewayStatsFunction · 0.85
SetMethod · 0.45
SetIfMaxMethod · 0.45
EqualMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected