MCPcopy Create free account
hub / github.com/docker/docker-language-server / TestWrite

Function TestWrite

internal/pkg/document/manager_test.go:40–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38}
39
40func TestWrite(t *testing.T) {
41 testCases := []struct {
42 name string
43 content string
44 newContent string
45 changed bool
46 }{
47 {
48 name: "FROM instruction has changed",
49 content: "FROM alpine:3.16.1",
50 newContent: "FROM alpine:3.16.2",
51 changed: true,
52 },
53 {
54 name: "whitespace added",
55 content: "FROM alpine:3.16.1",
56 newContent: "FROM alpine:3.16.1 ",
57 changed: false,
58 },
59 {
60 name: "newline moves content",
61 content: "FROM alpine:3.16.1",
62 newContent: "\nFROM alpine:3.16.1",
63 changed: true, // line numbers have changed
64 },
65 {
66 name: "newline at the end",
67 content: "FROM alpine:3.16.1 AS base",
68 newContent: "FROM alpine:3.16.1 \\\nAS base",
69 changed: true, // FROM now spans two lines
70 },
71 {
72 name: "comments are not considered a change",
73 content: "FROM scratch",
74 newContent: "FROM scratch\n# comment",
75 changed: false,
76 },
77 {
78 name: "syntax parser directive changed",
79 content: "#escape=\\\nFROM alpine:3.16.1 \\\nAS base",
80 newContent: "#escape=`\nFROM alpine:3.16.1 \\\nAS base",
81 changed: true,
82 },
83 {
84 name: "check parser directive changed",
85 content: "#\nFROM scratch",
86 newContent: "#check=skip=JSONArgsRecommended\nFROM scratch",
87 changed: true,
88 },
89 {
90 name: "add non check parser",
91 content: "FROM scratch",
92 newContent: "FROM scratch\n#check=skip=JSONArgsRecommended",
93 changed: false,
94 },
95 }
96
97 for _, tc := range testCases {

Callers

nothing calls this directly

Calls 4

NewDocumentManagerFunction · 0.85
RemoveMethod · 0.80
VersionMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected