MCPcopy Index your code
hub / github.com/cloudflare/cloudflared / TestRefreshFeaturesRecord

Function TestRefreshFeaturesRecord

features/selector_test.go:172–195  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

170}
171
172func TestRefreshFeaturesRecord(t *testing.T) {
173 percentages := []uint32{0, 10, testAccountHash - 1, testAccountHash, testAccountHash + 1, 100, 101, 1000}
174 selector := newTestSelector(t, percentages, false, time.Minute)
175
176 // Starting out should default to DatagramV2
177 snapshot := selector.Snapshot()
178 require.Equal(t, DatagramV2, snapshot.DatagramVersion)
179
180 for _, percentage := range percentages {
181 snapshot = selector.Snapshot()
182 if percentage > testAccountHash {
183 require.Equal(t, DatagramV3, snapshot.DatagramVersion)
184 } else {
185 require.Equal(t, DatagramV2, snapshot.DatagramVersion)
186 }
187
188 // Manually progress the next refresh
189 _ = selector.refresh(t.Context())
190 }
191
192 // Make sure a resolver error doesn't override the last fetched features
193 snapshot = selector.Snapshot()
194 require.Equal(t, DatagramV3, snapshot.DatagramVersion)
195}
196
197func TestSnapshotIsolation(t *testing.T) {
198 percentages := []uint32{testAccountHash, testAccountHash + 1}

Callers

nothing calls this directly

Calls 5

newTestSelectorFunction · 0.85
refreshMethod · 0.80
SnapshotMethod · 0.65
EqualMethod · 0.65
ContextMethod · 0.65

Tested by

no test coverage detected