Make plugin IDs case insensitive (#9117)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
275731578e
Коммит
f2c1803905
@@ -9,6 +9,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
@@ -201,6 +202,7 @@ func FindManifest(dir string) (manifest *Manifest, path string, err error) {
|
||||
return
|
||||
}
|
||||
manifest = &parsed
|
||||
manifest.Id = strings.ToLower(manifest.Id)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -220,5 +222,6 @@ func FindManifest(dir string) (manifest *Manifest, path string, err error) {
|
||||
return
|
||||
}
|
||||
manifest = &parsed
|
||||
manifest.Id = strings.ToLower(manifest.Id)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -27,9 +27,11 @@ func TestFindManifest(t *testing.T) {
|
||||
{"foo", "bar", true, true},
|
||||
{"plugin.json", "bar", true, false},
|
||||
{"plugin.json", `{"id": "foo"}`, false, false},
|
||||
{"plugin.json", `{"id": "FOO"}`, false, false},
|
||||
{"plugin.yaml", `id: foo`, false, false},
|
||||
{"plugin.yaml", "bar", true, false},
|
||||
{"plugin.yml", `id: foo`, false, false},
|
||||
{"plugin.yml", `id: FOO`, false, false},
|
||||
{"plugin.yml", "bar", true, false},
|
||||
} {
|
||||
dir, err := ioutil.TempDir("", "mm-plugin-test")
|
||||
@@ -54,6 +56,7 @@ func TestFindManifest(t *testing.T) {
|
||||
if !tc.ExpectError {
|
||||
require.NotNil(t, m, tc.Filename)
|
||||
assert.NotEmpty(t, m.Id, tc.Filename)
|
||||
assert.Equal(t, strings.ToLower(m.Id), m.Id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user