mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-28 21:48:25 +00:00
* feat: Add check for misspelled executable name command * Update server/utils/spellcheck_test.go Co-authored-by: Ken Kaizu <k.kaizu38@gmail.com> --------- Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> Co-authored-by: Ken Kaizu <k.kaizu38@gmail.com>
66 lines
954 B
Go
66 lines
954 B
Go
package utils_test
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/runatlantis/atlantis/server/utils"
|
|
. "github.com/runatlantis/atlantis/testing"
|
|
)
|
|
|
|
func Test_IsSimilarWord(t *testing.T) {
|
|
t.Log("check if given executable name is misspelled or just an unrelated word")
|
|
|
|
spellings := []struct {
|
|
Misspelled bool
|
|
Given string
|
|
Want string
|
|
}{
|
|
{
|
|
false,
|
|
"atlantis",
|
|
"atlantis",
|
|
},
|
|
{
|
|
false,
|
|
"maybe",
|
|
"atlantis",
|
|
},
|
|
{
|
|
false,
|
|
"atlantis-qa",
|
|
"atlantis-prod",
|
|
},
|
|
{
|
|
true,
|
|
"altantis",
|
|
"atlantis",
|
|
},
|
|
{
|
|
true,
|
|
"atlants",
|
|
"atlantis",
|
|
},
|
|
{
|
|
true,
|
|
"teraform",
|
|
"terraform",
|
|
},
|
|
}
|
|
|
|
for _, s := range spellings {
|
|
t.Run(fmt.Sprintf("given %s want %s", s.Given, s.Want), func(t *testing.T) {
|
|
isMisspelled := utils.IsSimilarWord(s.Given, s.Want)
|
|
|
|
if s.Misspelled {
|
|
Equals(t, isMisspelled, true)
|
|
}
|
|
|
|
if !s.Misspelled {
|
|
Equals(t, isMisspelled, false)
|
|
}
|
|
})
|
|
}
|
|
|
|
}
|