MCPcopy Index your code
hub / github.com/coder/coder / requireConvert

Function requireConvert

coderd/rbac/regosql/compile_test.go:385–410  ·  view source on GitHub ↗
(t *testing.T, tc convertTestCase)

Source from the content-addressed store, hash-verified

383}
384
385func requireConvert(t *testing.T, tc convertTestCase) {
386 t.Helper()
387
388 for i, q := range tc.part.Queries {
389 t.Logf("Query %d: %s", i, q.String())
390 }
391 for i, s := range tc.part.Support {
392 t.Logf("Support %d: %s", i, s.String())
393 }
394
395 root, err := regosql.ConvertRegoAst(tc.cfg, tc.part)
396 if tc.expectConvertError {
397 require.Error(t, err)
398 } else {
399 require.NoError(t, err, "compile")
400
401 gen := sqltypes.NewSQLGenerator()
402 sqlString := root.SQLString(gen)
403 if tc.expectSQLGenError {
404 require.True(t, len(gen.Errors()) > 0, "expected SQL generation error")
405 } else {
406 require.NoError(t, err, "sql gen")
407 require.Equal(t, tc.expectSQL, sqlString, "sql match")
408 }
409 }
410}
411
412func partialQueries(queries ...string) *rego.PartialQueries {
413 opts := ast.ParserOptions{

Callers 1

TestRegoQueriesFunction · 0.85

Calls 9

ErrorsMethod · 0.95
ConvertRegoAstFunction · 0.92
NewSQLGeneratorFunction · 0.92
HelperMethod · 0.65
LogfMethod · 0.65
SQLStringMethod · 0.65
StringMethod · 0.45
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected