MCPcopy Index your code
hub / github.com/ent/ent / TestParsePath

Function TestParsePath

dialect/sql/sqljson/sqljson_test.go:412–465  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

410}
411
412func TestParsePath(t *testing.T) {
413 tests := []struct {
414 input string
415 wantPath []string
416 wantErr bool
417 }{
418 {
419 input: "a.b.c",
420 wantPath: []string{"a", "b", "c"},
421 },
422 {
423 input: "a[1][2]",
424 wantPath: []string{"a", "[1]", "[2]"},
425 },
426 {
427 input: "a[1][2].b",
428 wantPath: []string{"a", "[1]", "[2]", "b"},
429 },
430 {
431 input: `a."b.c[0]"`,
432 wantPath: []string{"a", `"b.c[0]"`},
433 },
434 {
435 input: `a."b.c[0]".d`,
436 wantPath: []string{"a", `"b.c[0]"`, "d"},
437 },
438 {
439 input: `...`,
440 },
441 {
442 input: `.a.b.`,
443 wantPath: []string{"a", "b"},
444 },
445 {
446 input: `a."`,
447 wantErr: true,
448 },
449 {
450 input: `a[`,
451 wantErr: true,
452 },
453 {
454 input: `a[a]`,
455 wantErr: true,
456 },
457 }
458 for i, tt := range tests {
459 t.Run(strconv.Itoa(i), func(t *testing.T) {
460 path, err := sqljson.ParsePath(tt.input)
461 require.Equal(t, tt.wantPath, path)
462 require.Equal(t, tt.wantErr, err != nil)
463 })
464 }
465}
466
467func TestAppend(t *testing.T) {
468 tests := []struct {

Callers

nothing calls this directly

Calls 2

ParsePathFunction · 0.92
RunMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…