(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestGetInstruction(t *testing.T) { |
| 14 | testCases := []struct { |
| 15 | name string |
| 16 | content string |
| 17 | positions []protocol.Position |
| 18 | found []bool |
| 19 | instructions []string |
| 20 | }{ |
| 21 | { |
| 22 | name: "FROM alpine:3.16.1", |
| 23 | content: "FROM alpine:3.16.1", |
| 24 | positions: []protocol.Position{ |
| 25 | {Line: 0, Character: 0}, |
| 26 | {Line: 1, Character: 0}, |
| 27 | }, |
| 28 | found: []bool{ |
| 29 | true, false, |
| 30 | }, |
| 31 | instructions: []string{"FROM", ""}, |
| 32 | }, |
| 33 | } |
| 34 | |
| 35 | for _, tc := range testCases { |
| 36 | t.Run(tc.name, func(t *testing.T) { |
| 37 | opts := WithReadDocumentFunc(func(uri.URI) ([]byte, error) { |
| 38 | return []byte(tc.content), nil |
| 39 | }) |
| 40 | mgr := NewDocumentManager(opts) |
| 41 | doc, err := mgr.Read(context.Background(), "") |
| 42 | require.Nil(t, err) |
| 43 | |
| 44 | for i := range tc.positions { |
| 45 | instruction := doc.(DockerfileDocument).Instruction(tc.positions[i]) |
| 46 | if tc.found[i] { |
| 47 | require.NotNil(t, instruction) |
| 48 | require.Equal(t, tc.instructions[i], instruction.Value) |
| 49 | } else { |
| 50 | require.Nil(t, instruction) |
| 51 | } |
| 52 | } |
| 53 | }) |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | func TestUpdate(t *testing.T) { |
| 58 | testCases := []struct { |
nothing calls this directly
no test coverage detected