Skip to content

Commit

Permalink
test(definition): fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qvalentin committed Mar 31, 2024
1 parent 13c5680 commit 6c8523e
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
26 changes: 19 additions & 7 deletions internal/handler/definition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ func TestDefinitionValueInList(t *testing.T) {
URI: testValuesURI,
Range: lsp.Range{
Start: lsp.Position{
Line: 3,
Character: 2,
Line: 4,
Character: 0,
},
End: lsp.Position{
Line: 3,
Character: 2,
Line: 4,
Character: 0,
},
},
},
Expand Down Expand Up @@ -201,7 +201,11 @@ func TestDefinitionValueFile(t *testing.T) {
URI: testValuesURI,
Range: lsp.Range{
Start: lsp.Position{
Line: 0,
Line: 1,
Character: 0,
},
End: lsp.Position{
Line: 1,
Character: 0,
},
},
Expand Down Expand Up @@ -265,15 +269,23 @@ func TestDefinitionValueFileMulitpleValues(t *testing.T) {
URI: testValuesURI,
Range: lsp.Range{
Start: lsp.Position{
Line: 0,
Line: 1,
Character: 0,
},
End: lsp.Position{
Line: 1,
Character: 0,
},
},
}, {
URI: testOtherValuesURI,
Range: lsp.Range{
Start: lsp.Position{
Line: 0,
Line: 1,
Character: 0,
},
End: lsp.Position{
Line: 1,
Character: 0,
},
},
Expand Down
13 changes: 12 additions & 1 deletion internal/handler/hover_main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ func TestHoverMain(t *testing.T) {
expected: fmt.Sprintf("### %s\n%s\n\n", filepath.Join("..", "..", "testdata", "example", "values.yaml"), "ingress.hosts:\n- host: chart-example.local\n paths:\n - path: /\n pathType: ImplementationSpecific\n"),
expectedError: nil,
},
{
desc: "Test not existing values list",
position: lsp.Position{
Line: 101,
Character: 35,
},
expected: "",
expectedError: fmt.Errorf("Could not parse ast correctly"),
},
}
for _, tt := range testCases {
t.Run(tt.desc, func(t *testing.T) {
Expand Down Expand Up @@ -130,7 +139,9 @@ func TestHoverMain(t *testing.T) {
},
})
assert.Equal(t, tt.expectedError, err)
assert.Equal(t, tt.expected, result.Contents.Value)
if err == nil {
assert.Equal(t, tt.expected, result.Contents.Value)
}
})
}
}
4 changes: 3 additions & 1 deletion internal/handler/hover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ nested: value
splittedVar: []string{"key"},
},
want: `### values.yaml
[map[nested:value]]
key:
- nested: value
`,
wantErr: false,
Expand Down
1 change: 1 addition & 0 deletions testdata/example/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ spec:
{{- if $.Files.Glob "files/dags/*.py" }}
{{- end }}
{{- end }}
hosts: {{ .Values.ingress.hosts }}

0 comments on commit 6c8523e

Please sign in to comment.