summaryrefslogtreecommitdiff
path: root/test/handler/test_dockerfile_lint_handler.vader
blob: a73db8cd90dda328be7f694dd51d73c583bcad22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
Before:
  runtime ale_linters/dockerfile/dockerfile_lint.vim

After:
  call ale#linter#Reset()

Execute(The dockerfile_lint handler should handle broken JSON):
  AssertEqual
  \ [],
  \ ale_linters#dockerfile#dockerfile_lint#Handle(bufnr(''), ["{asdf"])

Execute(The dockerfile_lint handler should handle an empty string response):
  AssertEqual
  \ [],
  \ ale_linters#dockerfile#dockerfile_lint#Handle(bufnr(''), [])

Execute(The dockerfile_lint handler should handle an empty result, even if it shouldn't happen):
  AssertEqual
  \ [],
  \ ale_linters#dockerfile#dockerfile_lint#Handle(bufnr(''), ["{}"])

Execute(The dockerfile_lint handler should handle a normal example):
  AssertEqual
  \ [
  \   {
  \     'lnum': -1,
  \     'type': 'E',
  \     'text': "Required LABEL name/key 'Name' is not defined",
  \     'detail': "Required LABEL name/key 'Name' is not defined\n\nhttp://docs.projectatomic.io/container-best-practices/#_recommended_labels_for_your_project",
  \   },
  \   {
  \     'lnum': -1,
  \     'type': 'E',
  \     'text': "Required LABEL name/key 'Version' is not defined",
  \     'detail': "Required LABEL name/key 'Version' is not defined\n\nhttp://docs.projectatomic.io/container-best-practices/#_recommended_labels_for_your_project",
  \   },
  \   {
  \     'lnum': 3,
  \     'type': 'I',
  \     'text': "the MAINTAINER command is deprecated",
  \     'detail': "the MAINTAINER command is deprecated\n\nMAINTAINER is deprecated in favor of using LABEL since Docker v1.13.0\n\nhttps://github.com/docker/cli/blob/master/docs/deprecated.md#maintainer-in-dockerfile",
  \   },
  \   {
  \     'lnum': -1,
  \     'type': 'I',
  \     'text': "There is no 'CMD' instruction",
  \     'detail': "There is no 'CMD' instruction\n\nhttps://docs.docker.com/engine/reference/builder/#cmd",
  \   },
  \ ],
  \ ale_linters#dockerfile#dockerfile_lint#Handle(bufnr(''), [
  \  '{',
  \  '  "error": {',
  \  '    "count": 2,',
  \  '    "data": [',
  \  '      {',
  \  "        \"message\": \"Required LABEL name/key 'Name' is not defined\",",
  \  '        "line": -1,',
  \  '        "level": "error",',
  \  '        "lineContent": "",',
  \  '        "reference_url": [',
  \  '          "http://docs.projectatomic.io/container-best-practices/#",',
  \  '          "_recommended_labels_for_your_project"',
  \  '        ]',
  \  '      },',
  \  '      {',
  \  "        \"message\": \"Required LABEL name/key 'Version' is not defined\",",
  \  '        "line": -1,',
  \  '        "level": "error",',
  \  '        "lineContent": "",',
  \  '        "reference_url": [',
  \  '          "http://docs.projectatomic.io/container-best-practices/#",',
  \  '          "_recommended_labels_for_your_project"',
  \  '        ]',
  \  '      }',
  \  '    ]',
  \  '  },',
  \  '  "warn": {',
  \  '    "count": 0,',
  \  '    "data": []',
  \  '  },',
  \  '  "info": {',
  \  '    "count": 2,',
  \  '    "data": [',
  \  '      {',
  \  '        "label": "maintainer_deprecated",',
  \  '        "regex": {},',
  \  '        "level": "info",',
  \  '        "message": "the MAINTAINER command is deprecated",',
  \  '        "description": "MAINTAINER is deprecated in favor of using LABEL since Docker v1.13.0",',
  \  '        "reference_url": [',
  \  '          "https://github.com/docker/cli/blob/master/docs/deprecated.md",',
  \  '          "#maintainer-in-dockerfile"',
  \  '        ],',
  \  '        "lineContent": "MAINTAINER Alexander Olofsson <ace@haxalot.com>",',
  \  '        "line": 3',
  \  '      },',
  \  '      {',
  \  '        "instruction": "CMD",',
  \  '        "count": 1,',
  \  '        "level": "info",',
  \  "        \"message\": \"There is no 'CMD' instruction\",",
  \  '        "description": "None",',
  \  '        "reference_url": [',
  \  '          "https://docs.docker.com/engine/reference/builder/",',
  \  '          "#cmd"',
  \  '        ]',
  \  '      }',
  \  '    ]',
  \  '  },',
  \  '  "summary": []',
  \  '}',
  \ ])