grafana/pkg/cmd/grafana-cli/commands/upgrade_all_command_test.go

50 lines
1.1 KiB
Go
Raw Normal View History

2016-02-15 07:09:34 -06:00
package commands
import (
"fmt"
2016-02-15 07:09:34 -06:00
"testing"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
"github.com/stretchr/testify/assert"
2016-02-15 07:09:34 -06:00
)
func TestVersionComparison(t *testing.T) {
t.Run("Validate that version is outdated", func(t *testing.T) {
versions := []models.Version{
2016-02-15 07:09:34 -06:00
{Version: "1.1.1"},
{Version: "2.0.0"},
}
upgradeablePlugins := map[string]models.Plugin{
2016-02-15 07:09:34 -06:00
"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))
})
}
2016-02-15 07:09:34 -06:00
})
t.Run("Validate that version is ok", func(t *testing.T) {
versions := []models.Version{
2016-02-15 07:09:34 -06:00
{Version: "1.1.1"},
{Version: "2.0.0"},
}
shouldNotUpgrade := map[string]models.Plugin{
2016-02-15 07:09:34 -06:00
"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))
})
}
2016-02-15 07:09:34 -06:00
})
}