#129 Fix plugin version validation

This commit is contained in:
Jakub Al-Khalili 2019-10-09 12:35:47 +02:00
parent bad8236104
commit 9b25919d7c
2 changed files with 10 additions and 1 deletions

View File

@ -23,7 +23,7 @@ func (p Plugin) String() string {
var (
namePattern = regexp.MustCompile(`(?i)^[0-9a-z-_]+$`)
versionPattern = regexp.MustCompile(`^[0-9\\.]+$`)
versionPattern = regexp.MustCompile(`^[0-9\\.-]+$`)
)
// New creates plugin from string, for example "name-of-plugin:0.0.1"

View File

@ -108,4 +108,13 @@ func TestVerifyDependencies(t *testing.T) {
got := VerifyDependencies(basePlugins, extraPlugins)
assert.Equal(t, false, got)
})
t.Run("happy with dash in version", func(t *testing.T) {
basePlugins := map[Plugin][]Plugin{
Must(New("first-root-plugin:1.0.0-1")): {
Must(New("first-plugin:0.0.1-1")),
},
}
got := VerifyDependencies(basePlugins)
assert.Equal(t, true, got)
})
}