MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestSubsetMacro

Function TestSubsetMacro

common/env/env_test.go:1243–1307  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1241}
1242
1243func TestSubsetMacro(t *testing.T) {
1244 tests := []struct {
1245 name string
1246 lib *LibrarySubset
1247 macroName string
1248 included bool
1249 }{
1250 {
1251 name: "nil lib, included",
1252 macroName: "has",
1253 included: true,
1254 },
1255 {
1256 name: "empty, included",
1257 lib: NewLibrarySubset(),
1258 macroName: "has",
1259 included: true,
1260 },
1261 {
1262 name: "empty, disabled",
1263 lib: NewLibrarySubset().SetDisabled(true),
1264 macroName: "has",
1265 included: false,
1266 },
1267 {
1268 name: "empty, included",
1269 lib: NewLibrarySubset().SetDisableMacros(true),
1270 macroName: "has",
1271 included: false,
1272 },
1273 {
1274 name: "lib, not included allow-list",
1275 lib: NewLibrarySubset().AddIncludedMacros("exists"),
1276 macroName: "has",
1277 included: false,
1278 },
1279 {
1280 name: "lib, included allow-list",
1281 lib: NewLibrarySubset().AddIncludedMacros("exists"),
1282 macroName: "exists",
1283 included: true,
1284 },
1285 {
1286 name: "lib, not included deny-list",
1287 lib: NewLibrarySubset().AddExcludedMacros("exists"),
1288 macroName: "exists",
1289 included: false,
1290 },
1291 {
1292 name: "lib, included deny-list",
1293 lib: NewLibrarySubset().AddExcludedMacros("exists"),
1294 macroName: "has",
1295 included: true,
1296 },
1297 }
1298 for _, tst := range tests {
1299 tc := tst
1300 t.Run(tc.name, func(t *testing.T) {

Callers

nothing calls this directly

Calls 6

NewLibrarySubsetFunction · 0.85
SetDisabledMethod · 0.80
SetDisableMacrosMethod · 0.80
AddIncludedMacrosMethod · 0.80
AddExcludedMacrosMethod · 0.80
SubsetMacroMethod · 0.80

Tested by

no test coverage detected