(t *testing.T)
| 55 | } |
| 56 | |
| 57 | func TestUpdate(t *testing.T) { |
| 58 | testCases := []struct { |
| 59 | name string |
| 60 | content string |
| 61 | newContent string |
| 62 | hasNodes bool |
| 63 | instructionValue string |
| 64 | }{ |
| 65 | { |
| 66 | name: "syntax error interrupts parsing", |
| 67 | content: "FROM alpine:3.16.1", |
| 68 | newContent: "FROM alpine:3.16.1\nRUN <<a", |
| 69 | hasNodes: false, |
| 70 | instructionValue: "", |
| 71 | }, |
| 72 | { |
| 73 | name: "instruction completely changed", |
| 74 | content: "FROM alpine:3.16.1", |
| 75 | newContent: "ARG imageTag", |
| 76 | hasNodes: true, |
| 77 | instructionValue: "ARG", |
| 78 | }, |
| 79 | } |
| 80 | |
| 81 | for _, tc := range testCases { |
| 82 | t.Run(tc.name, func(t *testing.T) { |
| 83 | document := NewDocument(NewDocumentManager(), "", protocol.DockerfileLanguage, 1, []byte(tc.content)) |
| 84 | document.Update(2, []byte(tc.newContent)) |
| 85 | if tc.hasNodes { |
| 86 | require.Equal(t, tc.instructionValue, document.(DockerfileDocument).Nodes()[0].Value) |
| 87 | } else { |
| 88 | require.Len(t, document.(DockerfileDocument).Nodes(), 0) |
| 89 | } |
| 90 | }) |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | func TestGetDecoder(t *testing.T) { |
| 95 | testCases := []struct { |
nothing calls this directly
no test coverage detected