diff --git a/internal/adapter/yamlls/yamlls_test.go b/internal/adapter/yamlls/yamlls_test.go index af0ae63..b1a42d1 100644 --- a/internal/adapter/yamlls/yamlls_test.go +++ b/internal/adapter/yamlls/yamlls_test.go @@ -1,6 +1,7 @@ package yamlls import ( + "os" "testing" lsplocal "github.com/mrjosh/helm-ls/internal/lsp" @@ -17,13 +18,20 @@ func TestIsRelevantFile(t *testing.T) { } connector.documents = &lsplocal.DocumentStore{} - yamlFile := uri.File("../../../testdata/example/templates/deployment.yaml") - nonYamlFile := uri.File("../../../testdata/example/templates/_helpers.tpl") - connector.documents.Store(yamlFile, util.DefaultConfig) - connector.documents.Store(nonYamlFile, util.DefaultConfig) + yamlFile := "../../../testdata/example/templates/deployment.yaml" + nonYamlFile := "../../../testdata/example/templates/_helpers.tpl" - assert.True(t, connector.isRelevantFile(yamlFile)) - assert.False(t, connector.isRelevantFile(nonYamlFile)) + yamlFileContent, err := os.ReadFile(yamlFile) + assert.NoError(t, err) + + nonYamlFileContent, err := os.ReadFile(nonYamlFile) + assert.NoError(t, err) + + connector.documents.Store(yamlFile, yamlFileContent, util.DefaultConfig) + connector.documents.Store(nonYamlFile, nonYamlFileContent, util.DefaultConfig) + + assert.True(t, connector.isRelevantFile(uri.File(yamlFile))) + assert.False(t, connector.isRelevantFile(uri.File(nonYamlFile))) } func TestShouldRun(t *testing.T) { diff --git a/internal/lsp/document_store.go b/internal/lsp/document_store.go index 07379b2..860e7b0 100644 --- a/internal/lsp/document_store.go +++ b/internal/lsp/document_store.go @@ -53,7 +53,7 @@ func (s *DocumentStore) DidOpen(params *lsp.DidOpenTextDocumentParams, helmlsCon func (s *DocumentStore) Store(filename string, content []byte, helmlsConfig util.HelmlsConfiguration) { ast := ParseAst(nil, string(content)) fileUri := uri.File(filename) - s.documents.Store(filename, + s.documents.Store(fileUri, &Document{ URI: fileUri, Path: filename,