Debian Codegraph @

integration/_fixtures/semver_fixture/semver_test.go

raw
1 package semver_fixture_test
2
3 import (
4 . "github.com/onsi/ginkgo/v2"
5 . "github.com/onsi/gomega"
6 )
7
8 var _ = Describe("Semantic Version Filtering", func() {
9 It("should run without constraints", func() {})
10
11 It("should run with version in range [2.0.0, ~)", SemVerConstraint(">= 2.0.0"), func() {})
12
13 It("should run with version in range [2.0.0, 3.0.0)", SemVerConstraint(">= 2.0.0, < 3.0.0"), func() {})
14
15 It("should run with version in range [2.0.0, 4.0.0)", SemVerConstraint(">= 2.0.0", "< 4.0.0"), func() {})
16
17 It("should run with version in range [2.0.0, 5.0.0)", SemVerConstraint(">= 2.0.0"), SemVerConstraint("< 5.0.0"), func() {})
18
19 It("should run with ComponentA in range [2.0.0, ~)", ComponentSemVerConstraint("ComponentA", ">= 2.0.0"), func() {})
20
21 It("should run with ComponentA in range [2.0.0, 3.0.0)", ComponentSemVerConstraint("ComponentA", ">= 2.0.0, < 3.0.0"), func() {})
22
23 It("should run with ComponentA in range [2.0.0, 4.0.0)", ComponentSemVerConstraint("ComponentA", ">= 2.0.0", "< 4.0.0"), func() {})
24
25 It("should run with ComponentA in range [2.0.0, 5.0.0)", ComponentSemVerConstraint("ComponentA", ">= 2.0.0"), ComponentSemVerConstraint("ComponentA", "< 5.0.0"), func() {})
26
27 It("should run with a mixed of component-specific and non-component constraints", SemVerConstraint(">= 2.0.0"), ComponentSemVerConstraint("ComponentA", ">= 2.0.0"), func() {})
28
29 It("shouldn't run with version in a conflict range", SemVerConstraint("2.0.0 - 6.0.0"), SemVerConstraint("<= 1.0.0"), func() {})
30
31 It("shouldn't run with ComponentA in a conflict range", ComponentSemVerConstraint("ComponentA", "2.0.0 - 6.0.0"), ComponentSemVerConstraint("ComponentA", "<= 1.0.0"), func() {})
32
33 It("shouldn't run with a mixed of component-specific and non-component conflict constraints", SemVerConstraint(">= 2.0.0"), ComponentSemVerConstraint("ComponentA", "<= 1.0.0"), func() {})
34 })
35
36 var _ = Describe("Hierarchy Semantic Version Filtering", func() {
37 Context("with container constraints", SemVerConstraint(">= 2.0.0", "< 3.0.0"), func() {
38 It("should inherit container constraint", func() {})
39
40 It("should narrow down the constraint", SemVerConstraint(">= 2.1.0, < 2.8.0"), func() {})
41
42 It("shouldn't expand the constraint", SemVerConstraint("< 4.0.0"), func() {
43 // If you pass '--sem-ver-filter=3.5.0', then the whole Context would be skipped since it doesn't match the top level SemVerConstraints.
44 // But if you pass '--sem-ver-filter=2.5.0', this test case would keep running since it matches the combined constraint '>= 2.0.0, < 3.0.0, < 4.0.0'
45 })
46
47 It("shouldn't combine with a conflict constraint", SemVerConstraint("< 1.0.0"), func() {
48 // The new combined constraint is '>= 2.0.0, < 3.0.0, <1.0.0', there's no such a version can match this constraint.
49 // So, this test case would be skipped.
50 })
51 })
52
53 Context("with container component-specific constraints", ComponentSemVerConstraint("ComponentA", ">= 2.0.0", "< 3.0.0"), func() {
54 It("should inherit container component-specific constraint", func() {})
55
56 It("should narrow down the component-specific constraint", ComponentSemVerConstraint("ComponentA", ">= 2.1.0, < 2.8.0"), func() {})
57
58 It("shouldn't expand the component-specific constraint", ComponentSemVerConstraint("ComponentA", "< 4.0.0"), func() {
59 // If you pass '--sem-ver-filter=3.5.0', then the whole Context would be skipped since it doesn't match the top level ComponentSemVerConstraints.
60 // But if you pass '--sem-ver-filter=2.5.0', this test case would keep running since it matches the combined constraint '>= 2.0.0, < 3.0.0, < 4.0.0'
61 })
62
63 It("shouldn't combine with a component-specific conflict constraint", ComponentSemVerConstraint("ComponentA", "< 1.0.0"), func() {
64 // The new combined constraint is '>= 2.0.0, < 3.0.0, <1.0.0', there's no such a version can match this constraint.
65 // So, this test case would be skipped.
66 })
67 })
68
69 Context("with mixed container constraints", SemVerConstraint(">= 2.0.0", "< 3.0.0"),
70 ComponentSemVerConstraint("ComponentA", ">= 2.0.0", "< 3.0.0"), func() {
71 It("should inherit container constraints and a new component-specific constraint", ComponentSemVerConstraint("ComponentB", ">= 0.1.0"), func() {})
72 })
73 })
74
75 var _ = DescribeTable("Semantic Version Filtering in table-driven spec", func() {
76 Expect(true).To(BeTrue())
77 },
78 Entry("should run without constraints by table driven"),
79 Entry("should run with version in range [2.0.0, ~) by table driven", SemVerConstraint(">= 2.0.0")),
80 Entry("shouldn't run with version in a conflict range by table driven", SemVerConstraint(">= 2.0.0"), SemVerConstraint("~1.2.3")),
81 Entry("should run with ComponentA in range [2.0.0, ~) by table driven", ComponentSemVerConstraint("ComponentA", ">= 2.0.0")),
82 Entry("shouldn't run with ComponentA in a conflict range by table driven", ComponentSemVerConstraint("ComponentA", ">= 2.0.0"), ComponentSemVerConstraint("ComponentA", "~1.2.3")),
83 Entry("should run with mixed constraints by table driven", SemVerConstraint(">= 2.0.0"), ComponentSemVerConstraint("ComponentA", ">= 2.0.0")),
84 )