...

Text file src/cuelang.org/go/tools/trim/testdata/shared.txtar

Documentation: cuelang.org/go/tools/trim/testdata

     1// Removing fields from shared nodes not supported.
     2-- in.cue --
     3import "strings"
     4
     5// TODO: this would be okay to normalize. Consider whether
     6// this makes sense, though.
     7a: {
     8	service: [ID=_]: name: "a"
     9
    10	service: foo: shared
    11	service: bar: shared
    12
    13	shared: name: "a"
    14}
    15
    16issue760: {
    17
    18	service: [ID=_]: {
    19		name: ID
    20	}
    21	service: foo: _shared
    22	service: bar: _shared
    23	_shared: {
    24		name: "foo" // Do not remove!
    25	}
    26}
    27
    28issue760: {
    29	service: [ID=_]: {
    30		_service_name: *strings.TrimSuffix(ID, "-suffix") | string
    31	}
    32	service: "a-suffix": _shared
    33	service: "b-suffix": _shared
    34	_shared: {
    35		_service_name: "a" // Do not remove!
    36	}
    37}
    38-- out/trim --
    39== in.cue
    40import "strings"
    41
    42// TODO: this would be okay to normalize. Consider whether
    43// this makes sense, though.
    44a: {
    45	service: [ID=_]: name: "a"
    46
    47	service: foo: shared
    48	service: bar: shared
    49
    50	shared: name: "a"
    51}
    52
    53issue760: {
    54
    55	service: [ID=_]: {
    56		name: ID
    57	}
    58	service: foo: _shared
    59	service: bar: _shared
    60	_shared: {
    61		name: "foo" // Do not remove!
    62	}
    63}
    64
    65issue760: {
    66	service: [ID=_]: {
    67		_service_name: *strings.TrimSuffix(ID, "-suffix") | string
    68	}
    69	service: "a-suffix": _shared
    70	service: "b-suffix": _shared
    71	_shared: {
    72		_service_name: "a" // Do not remove!
    73	}
    74}

View as plain text