The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/cmd/grafana-cli/commands/upgrade_all_command_test.go

50 lines
1.1 KiB

package commands
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
)
func TestVersionComparison(t *testing.T) {
t.Run("Validate that version is outdated", func(t *testing.T) {
versions := []models.Version{
{Version: "1.1.1"},
{Version: "2.0.0"},
}
upgradeablePlugins := map[string]models.Plugin{
"0.0.0": {Versions: versions},
"1.0.0": {Versions: versions},
}
for k, v := range upgradeablePlugins {
val := v
t.Run(fmt.Sprintf("for %s should be true", k), func(t *testing.T) {
assert.True(t, shouldUpgrade(k, &val))
})
}
})
t.Run("Validate that version is ok", func(t *testing.T) {
versions := []models.Version{
{Version: "1.1.1"},
{Version: "2.0.0"},
}
shouldNotUpgrade := map[string]models.Plugin{
"2.0.0": {Versions: versions},
"6.0.0": {Versions: versions},
}
for k, v := range shouldNotUpgrade {
val := v
t.Run(fmt.Sprintf("for %s should be false", k), func(t *testing.T) {
assert.False(t, shouldUpgrade(k, &val))
})
}
})
}