databricks-cli/bundle/internal/schema/annotations_test.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
2.0 KiB
Go
Raw Normal View History

package main
import (
"testing"
)
func TestConvertLinksToAbsoluteUrl(t *testing.T) {
tests := []struct {
input string
expected string
}{
2025-01-10 16:47:06 +00:00
// {
// input: "",
// expected: "",
// },
// {
// input: "Some text (not a link)",
// expected: "Some text (not a link)",
// },
// {
// input: "This is a link to [_](#section)",
// expected: "This is a link to [section](https://docs.databricks.com/dev-tools/bundles/reference.html#section)",
// },
// {
// input: "This is a link to [_](/dev-tools/bundles/resources.html#dashboard)",
// expected: "This is a link to [dashboard](https://docs.databricks.com/dev-tools/bundles/resources.html#dashboard)",
// },
// {
// input: "This is a link to [_](/dev-tools/bundles/resources.html)",
// expected: "This is a link to [link](https://docs.databricks.com/dev-tools/bundles/resources.html)",
// },
// {
// input: "This is a link to [external](https://external.com)",
// expected: "This is a link to [external](https://external.com)",
// },
// {
// input: "This is a link to [pipelines](/api/workspace/pipelines/create)",
// expected: "This is a link to [pipelines](https://docs.databricks.com/api/workspace/pipelines/create)",
// },
{
2025-01-10 16:47:06 +00:00
input: "The registered model resource allows you to define models in \u003cUC\u003e. For information about \u003cUC\u003e [registered models](/api/workspace/registeredmodels/create), [registered models 2](/api/workspace/registeredmodels/create)",
expected: "The registered model resource allows you to define models in \u003cUC\u003e. For information about \u003cUC\u003e [registered models](/api/workspace/registeredmodels/create), [registered models 2](/api/workspace/registeredmodels/create)",
},
}
for _, test := range tests {
result := convertLinksToAbsoluteUrl(test.input)
if result != test.expected {
t.Errorf("For input '%s', expected '%s', but got '%s'", test.input, test.expected, result)
}
}
}