fixbug: ChartAndVersion did not handle chart version correct in some case (#98)

* fixbug: ChartAndVersion did not handle chart version correct in some case

https://github.com/komodorio/helm-dashboard/issues/95

* use regexp to get version

* add test case
This commit is contained in:
denganliang
2022-11-15 23:12:07 +08:00
committed by GitHub
parent cf407c63a2
commit 1393b117cf
2 changed files with 38 additions and 7 deletions

View File

@@ -1,9 +1,10 @@
package utils
import (
"github.com/gin-gonic/gin"
"net/http/httptest"
"testing"
"github.com/gin-gonic/gin"
)
func TestGetQueryProps(t *testing.T) {
@@ -69,6 +70,27 @@ func TestChartAndVersion(t *testing.T) {
wantVer: "1.0.0",
wantError: false,
},
{
name: "Chart and version - successfully parsing chart and version",
params: "chart-v1.0.0",
wantChart: "chart",
wantVer: "v1.0.0",
wantError: false,
},
{
name: "Chart and version - successfully parsing chart and version",
params: "chart-v1.0.0-alpha",
wantChart: "chart",
wantVer: "v1.0.0-alpha",
wantError: false,
},
{
name: "Chart and version - successfully parsing chart and version",
params: "chart-1.0.0-alpha",
wantChart: "chart",
wantVer: "1.0.0-alpha",
wantError: false,
},
{
name: "Chart and version - parsing chart without version",
params: "chart",