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

Function TestHasLabel

profile/profile_test.go:1084–1147  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1082}
1083
1084func TestHasLabel(t *testing.T) {
1085 var testcases = []struct {
1086 desc string
1087 labels map[string][]string
1088 key string
1089 value string
1090 wantHasLabel bool
1091 }{
1092 {
1093 desc: "empty label does not have label",
1094 labels: map[string][]string{},
1095 key: "key",
1096 value: "value",
1097 wantHasLabel: false,
1098 },
1099 {
1100 desc: "label with one key and value has label",
1101 labels: map[string][]string{"key": {"value"}},
1102 key: "key",
1103 value: "value",
1104 wantHasLabel: true,
1105 },
1106 {
1107 desc: "label with one key and value does not have label",
1108 labels: map[string][]string{"key": {"value"}},
1109 key: "key1",
1110 value: "value1",
1111 wantHasLabel: false,
1112 },
1113 {
1114 desc: "label with many keys and values has label",
1115 labels: map[string][]string{
1116 "key1": {"value2", "value1"},
1117 "key2": {"value1", "value2", "value2"},
1118 "key3": {"value1", "value2", "value2"},
1119 },
1120 key: "key1",
1121 value: "value1",
1122 wantHasLabel: true,
1123 },
1124 {
1125 desc: "label with many keys and values does not have label",
1126 labels: map[string][]string{
1127 "key1": {"value2", "value1"},
1128 "key2": {"value1", "value2", "value2"},
1129 "key3": {"value1", "value2", "value2"},
1130 },
1131 key: "key5",
1132 value: "value5",
1133 wantHasLabel: false,
1134 },
1135 }
1136
1137 for _, tc := range testcases {
1138 t.Run(tc.desc, func(t *testing.T) {
1139 sample := &Sample{
1140 Label: tc.labels,
1141 }

Callers

nothing calls this directly

Calls 1

HasLabelMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…