kuma

Форк
0
/
compatibility_test.go 
83 строки · 2.9 Кб
1
package version_test
2

3
import (
4
	. "github.com/onsi/ginkgo/v2"
5
	. "github.com/onsi/gomega"
6

7
	. "github.com/kumahq/kuma/pkg/version"
8
)
9

10
var _ = Describe("Version Compatibility", func() {
11
	It("should accept <= two prior minor versions", func() {
12
		result := DeploymentVersionCompatible("1.4.0", "1.4.1")
13
		Expect(result).To(BeTrue())
14
		result = DeploymentVersionCompatible("1.4.1", "1.4.0")
15
		Expect(result).To(BeTrue())
16
		result = DeploymentVersionCompatible("1.4.1", "1.3.5")
17
		Expect(result).To(BeTrue())
18
		result = DeploymentVersionCompatible("1.4.1", "1.2.0")
19
		Expect(result).To(BeTrue())
20
	})
21

22
	It("should accept <= two latter minor versions", func() {
23
		result := DeploymentVersionCompatible("1.4.0", "1.4.1")
24
		Expect(result).To(BeTrue())
25
		result = DeploymentVersionCompatible("1.4.1", "1.4.0")
26
		Expect(result).To(BeTrue())
27
		result = DeploymentVersionCompatible("1.3.1", "1.4.5")
28
		Expect(result).To(BeTrue())
29
		result = DeploymentVersionCompatible("1.2.1", "1.4.0")
30
		Expect(result).To(BeTrue())
31
	})
32

33
	It("should reject > two prior minor versions", func() {
34
		result := DeploymentVersionCompatible("1.4.0", "1.1.1")
35
		Expect(result).To(BeFalse())
36
		result = DeploymentVersionCompatible("1.4.1", "1.1.0")
37
		Expect(result).To(BeFalse())
38
		result = DeploymentVersionCompatible("1.4.1", "1.0.5")
39
		Expect(result).To(BeFalse())
40
		result = DeploymentVersionCompatible("1.4.1", "1.0.0")
41
		Expect(result).To(BeFalse())
42
	})
43

44
	It("should reject > two latter minor versions", func() {
45
		result := DeploymentVersionCompatible("1.4.0", "1.7.1")
46
		Expect(result).To(BeFalse())
47
		result = DeploymentVersionCompatible("1.4.1", "1.8.0")
48
		Expect(result).To(BeFalse())
49
		result = DeploymentVersionCompatible("1.3.1", "1.6.5")
50
		Expect(result).To(BeFalse())
51
		result = DeploymentVersionCompatible("1.2.1", "1.5.0")
52
		Expect(result).To(BeFalse())
53
	})
54

55
	It("should reject disparate major versions", func() {
56
		result := DeploymentVersionCompatible("1.4.0", "2.4.0")
57
		Expect(result).To(BeFalse())
58
		result = DeploymentVersionCompatible("2.4.1", "1.4.1")
59
		Expect(result).To(BeFalse())
60
		result = DeploymentVersionCompatible("1.0.0", "2.1.1")
61
		Expect(result).To(BeFalse())
62
		result = DeploymentVersionCompatible("2.2.2", "1.0.0")
63
		Expect(result).To(BeFalse())
64
	})
65

66
	It("should always accept dev versions", func() {
67
		result := DeploymentVersionCompatible("1.4.0", "dev-1234")
68
		Expect(result).To(BeTrue())
69
		result = DeploymentVersionCompatible("abc-dev-1234", "1.4.0")
70
		Expect(result).To(BeTrue())
71
	})
72

73
	It("should not underflow while decrementing acceptable versions", func() {
74
		result := DeploymentVersionCompatible("1.0.0", "1.1.0")
75
		Expect(result).To(BeTrue())
76
		result = DeploymentVersionCompatible("1.1.0", "1.0.0")
77
		Expect(result).To(BeTrue())
78
		result = DeploymentVersionCompatible("dev-abcd", "1.0.0")
79
		Expect(result).To(BeTrue())
80
		result = DeploymentVersionCompatible("1.0.0", "dev-abcd")
81
		Expect(result).To(BeTrue())
82
	})
83
})
84

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.