MCPcopy
hub / github.com/pelletier/go-toml / TestDecodeErrorRedefinition

Function TestDecodeErrorRedefinition

errors_test.go:424–532  ·  view source on GitHub ↗

TestDecodeErrorRedefinition checks that errors raised by the duplicate-key tracker are reported as DecodeError, carrying the key path and a position pointing at the offending key (see issue #668).

(t *testing.T)

Source from the content-addressed store, hash-verified

422// tracker are reported as DecodeError, carrying the key path and a position
423// pointing at the offending key (see issue #668).
424func TestDecodeErrorRedefinition(t *testing.T) {
425 examples := []struct {
426 desc string
427 doc string
428 msg string
429 key Key
430 row int
431 col int
432 human string
433 }{
434 {
435 desc: "duplicate key",
436 doc: "a = 1\nb = 2\nb = 3\n",
437 msg: "toml: key b is already defined",
438 key: Key{"b"},
439 row: 3,
440 col: 1,
441 human: `
4421| a = 1
4432| b = 2
4443| b = 3
445 | ~ key b is already defined`,
446 },
447 {
448 desc: "duplicate dotted key",
449 doc: "foo.bar = 1\nfoo.bar = 2\n",
450 msg: "toml: key bar is already defined",
451 key: Key{"foo", "bar"},
452 row: 2,
453 col: 1,
454 human: `
4551| foo.bar = 1
4562| foo.bar = 2
457 | ~~~~~~~ key bar is already defined`,
458 },
459 {
460 desc: "redefined table",
461 doc: "[a]\nx = 1\n[a]\ny = 2\n",
462 msg: "toml: table a already exists",
463 key: Key{"a"},
464 row: 3,
465 col: 2,
466 },
467 {
468 desc: "duplicate key in table body",
469 doc: "[a]\nx = 1\nx = 2\n",
470 msg: "toml: key x is already defined",
471 key: Key{"x"},
472 row: 3,
473 col: 1,
474 },
475 {
476 desc: "redefined nested table",
477 doc: "[a.b]\n[a.b]\n",
478 msg: "toml: table b already exists",
479 key: Key{"a", "b"},
480 row: 2,
481 col: 2,

Callers

nothing calls this directly

Calls 7

ErrorMethod · 0.95
KeyMethod · 0.95
PositionMethod · 0.95
StringMethod · 0.95
EqualFunction · 0.92
FatalfMethod · 0.80
UnmarshalFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…