MCPcopy
hub / github.com/docker/compose / TestReplace

Function TestReplace

pkg/compose/transform/replace_test.go:26–85  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestReplace(t *testing.T) {
27 tests := []struct {
28 name string
29 in string
30 want string
31 }{
32 {
33 name: "simple",
34 in: `services:
35 test:
36 extends:
37 file: foo.yaml
38 service: foo
39`,
40 want: `services:
41 test:
42 extends:
43 file: REPLACED
44 service: foo
45`,
46 },
47 {
48 name: "last line",
49 in: `services:
50 test:
51 extends:
52 service: foo
53 file: foo.yaml
54`,
55 want: `services:
56 test:
57 extends:
58 service: foo
59 file: REPLACED
60`,
61 },
62 {
63 name: "last line no CR",
64 in: `services:
65 test:
66 extends:
67 service: foo
68 file: foo.yaml`,
69 want: `services:
70 test:
71 extends:
72 service: foo
73 file: REPLACED`,
74 },
75 }
76 for _, tt := range tests {
77 t.Run(tt.name, func(t *testing.T) {
78 got, err := ReplaceExtendsFile([]byte(tt.in), "test", "REPLACED")
79 assert.NilError(t, err)
80 if !reflect.DeepEqual(got, []byte(tt.want)) {
81 t.Errorf("ReplaceExtendsFile() got = %v, want %v", got, tt.want)
82 }
83 })

Callers

nothing calls this directly

Calls 1

ReplaceExtendsFileFunction · 0.85

Tested by

no test coverage detected