mirror of
https://github.com/SigNoz/signoz.git
synced 2026-06-20 15:20:31 +01:00
Some checks failed
build-staging / js-build (push) Has been cancelled
build-staging / prepare (push) Has been cancelled
build-staging / go-build (push) Has been cancelled
build-staging / staging (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
* feat: extend error responses with new error struct
* fix: enriched error for dashboard api
* fix: merge issues
* fix: reverted dashboards changes and add for cloud integrations
* fix: delete file
* fix: add back file
* fix: added a helper
* fix: removed invlaid referencess
* fix: generate openapi
* fix: keeping additional along with suggestion
* Revert "fix: keeping additional along with suggestion"
This reverts commit be30e2ffd2.
* fix: added suggestions per additonal error
* fix: generate openapi
* fix: remove valid references
* fix: removeg valid references for select and group by and only did you mean is kept
* fix: unit test
* fix: use binding for deconding for both ee and community
* fix: trim down suggestions methods
* fix: added renamed methods and moved stuff around
* fix: typo
* fix: removed json decoder
* fix: added empty check
* fix: retain addtional
* fix: reverted re-structing of file
32 lines
947 B
Go
32 lines
947 B
Go
package errors
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestValidReferences(t *testing.T) {
|
|
// An empty set returns "" so callers don't surface a bare "valid references: ".
|
|
assert.Equal(t, "", ValidReferences[string]())
|
|
|
|
assert.Equal(t, "valid references: `a`, `b`", ValidReferences("a", "b"))
|
|
}
|
|
|
|
func TestSuggestionsOnLevenshteinDistance(t *testing.T) {
|
|
// No valid inputs => no suggestions at all (no bare "valid references: ").
|
|
assert.Empty(t, SuggestionsOnLevenshteinDistance("foo", nil))
|
|
|
|
// Close match => did-you-mean plus the valid-references list.
|
|
assert.Equal(t,
|
|
[]string{"did you mean: `name`", "valid references: `name`, `color`"},
|
|
SuggestionsOnLevenshteinDistance("nam", []string{"name", "color"}),
|
|
)
|
|
|
|
// No close match => valid-references list only.
|
|
assert.Equal(t,
|
|
[]string{"valid references: `name`, `color`"},
|
|
SuggestionsOnLevenshteinDistance("zzzzz", []string{"name", "color"}),
|
|
)
|
|
}
|