-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
140 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
internal/adapter/yamlls/custom_schema_provider_integration_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
//go:build integration | ||
|
||
package yamlls | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"path" | ||
"testing" | ||
"time" | ||
|
||
"github.com/mrjosh/helm-ls/internal/util" | ||
"github.com/stretchr/testify/assert" | ||
lsp "go.lsp.dev/protocol" | ||
"go.lsp.dev/uri" | ||
) | ||
|
||
var TEST_JSON_SCHEMA = ` | ||
{ | ||
"$id": "https://example.com/address.schema.json", | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"description": "An address similar to http://microformats.org/wiki/h-card", | ||
"type": "object", | ||
"properties": { | ||
"postOfficeBox": { | ||
"type": "string" | ||
}, | ||
"countryName": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
` | ||
|
||
func TestYamllsCustomSchemaProviderIntegration(t *testing.T) { | ||
config := util.DefaultConfig.YamllsConfiguration | ||
config.Path = "yamlls-debug.sh" | ||
|
||
// tempDir := t.TempDir() | ||
tempDir := "/data/data/com.termux/files/usr/tmp/" | ||
schemaFile := path.Join(tempDir, "schema.json") | ||
// write schema | ||
err := os.WriteFile(schemaFile, []byte(TEST_JSON_SCHEMA), 0o644) | ||
assert.NoError(t, err) | ||
|
||
testFile := path.Join(tempDir, "test.yaml") | ||
err = os.WriteFile(testFile, []byte("c"), 0o644) | ||
assert.NoError(t, err) | ||
|
||
customHandler := NewCustomSchemaHandler( | ||
NewCustomSchemaProviderHandler( | ||
func(ctx context.Context, URI uri.URI) (uri.URI, error) { | ||
t.Log("Calling Schema provider") | ||
return "http://localhost:8000/schema.json", nil | ||
})) | ||
|
||
yamllsConnector, documents, _ := getYamlLsConnector(t, config, customHandler) | ||
openFile(t, documents, testFile, yamllsConnector) | ||
|
||
assert.EventuallyWithT(t, func(c *assert.CollectT) { | ||
result, _ := yamllsConnector.CallCompletion(context.Background(), &lsp.CompletionParams{ | ||
TextDocumentPositionParams: lsp.TextDocumentPositionParams{ | ||
TextDocument: lsp.TextDocumentIdentifier{ | ||
URI: uri.File(testFile), | ||
}, | ||
Position: lsp.Position{ | ||
Line: 0, | ||
Character: 1, | ||
}, | ||
}, | ||
}) | ||
assert.NotNil(c, result) | ||
if result == nil { | ||
t.Log("result is nil") | ||
return | ||
} | ||
t.Log("reuslt is", result) | ||
}, time.Second*20, time.Second*2) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters