forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel_test.go
69 lines (63 loc) · 1.45 KB
/
model_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2021 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package upgrades_test
import (
jc "github.com/juju/testing/checkers"
"github.com/juju/version/v2"
gc "gopkg.in/check.v1"
"github.com/juju/juju/testing"
"github.com/juju/juju/upgrades"
)
type ModelSuite struct {
testing.BaseSuite
}
var _ = gc.Suite(&ModelSuite{})
func (s *ModelSuite) TestUpgradeAllowed(c *gc.C) {
for _, t := range []struct {
from string
to string
allowed bool
minVers string
err string
}{
{
from: "2.8.0",
to: "3.0.0",
allowed: false,
minVers: upgrades.MinMajorUpgradeVersionValue[3],
}, {
from: "3.0-rc1",
to: "3.0.0",
allowed: true,
minVers: "0.0.0",
}, {
from: "2.9.0",
to: "3.0.0",
allowed: false,
minVers: upgrades.MinMajorUpgradeVersionValue[3],
}, {
from: "2.9.17",
to: "3.0.0",
allowed: true,
minVers: upgrades.MinMajorUpgradeVersionValue[3],
}, {
from: "2.9.17",
to: "4.0.0",
allowed: false,
minVers: "0.0.0",
err: `unknown version "4.0.0"`,
},
} {
from := version.MustParse(t.from)
to := version.MustParse(t.to)
minVers := version.MustParse(t.minVers)
allowed, vers, err := upgrades.UpgradeAllowed(from, to)
c.Assert(allowed, gc.Equals, t.allowed)
c.Assert(vers, gc.DeepEquals, minVers)
if t.err == "" {
c.Assert(err, jc.ErrorIsNil)
} else {
c.Assert(err, gc.ErrorMatches, t.err)
}
}
}