MCPcopy Create free account
hub / github.com/google/pprof / TestAssign

Function TestAssign

internal/driver/settings_test.go:215–247  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

213}
214
215func TestAssign(t *testing.T) {
216 baseConfig := currentConfig()
217 defer setCurrentConfig(baseConfig)
218
219 // Test assigning to a simple field.
220 if err := configure("nodecount", "20"); err != nil {
221 t.Errorf("error setting nodecount: %v", err)
222 }
223 if n := currentConfig().NodeCount; n != 20 {
224 t.Errorf("incorrect nodecount; expecting 20, got %d", n)
225 }
226
227 // Test assignment to a group field.
228 if err := configure("granularity", "files"); err != nil {
229 t.Errorf("error setting granularity: %v", err)
230 }
231 if g := currentConfig().Granularity; g != "files" {
232 t.Errorf("incorrect granularity; expecting %v, got %v", "files", g)
233 }
234
235 // Test assignment to one choice of a group field.
236 if err := configure("lines", "t"); err != nil {
237 t.Errorf("error setting lines: %v", err)
238 }
239 if g := currentConfig().Granularity; g != "lines" {
240 t.Errorf("incorrect granularity; expecting %v, got %v", "lines", g)
241 }
242
243 // Test assignment to invalid choice,
244 if err := configure("granularity", "cheese"); err == nil {
245 t.Errorf("allowed assignment of invalid granularity")
246 }
247}

Callers

nothing calls this directly

Calls 3

currentConfigFunction · 0.85
setCurrentConfigFunction · 0.85
configureFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…