-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlist_packages_test.go
More file actions
105 lines (96 loc) · 2.58 KB
/
list_packages_test.go
File metadata and controls
105 lines (96 loc) · 2.58 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package cmd_test
import (
"time"
"github.com/jedib0t/go-pretty/v6/table"
. "github.com/onsi/ginkgo/v2"
//. "github.com/onsi/gomega"
"github.com/stretchr/testify/mock"
"github.com/codesphere-cloud/oms/cli/cmd"
"github.com/codesphere-cloud/oms/internal/portal"
"github.com/codesphere-cloud/oms/internal/util"
)
var _ = Describe("ListPackages", func() {
var (
mockTableWriter *util.MockTableWriter
c cmd.ListBuildsCmd
internal bool
buildDate time.Time
)
JustBeforeEach(func() {
mockTableWriter = util.NewMockTableWriter(GinkgoT())
c = cmd.ListBuildsCmd{
Opts: cmd.ListBuildsOpts{
Internal: internal,
},
TableWriter: mockTableWriter,
}
buildDate, _ = time.Parse("2006-01-02", "2025-05-01")
// header is always appended
mockTableWriter.EXPECT().AppendHeader(mock.Anything)
mockTableWriter.EXPECT().Render().Return("")
})
Context("Internal packages are excluded", func() {
It("doesn't list internal packages, artifacts are separated by ,", func() {
mockTableWriter.EXPECT().AppendRow(
table.Row{"", "1.42", buildDate, "externalBuild", "installer.tar, installer2.tar"},
)
c.PrintPackagesTable(
portal.CodesphereBuilds{
Builds: []portal.CodesphereBuild{
{
Hash: "externalBuild",
Version: "1.42",
Date: buildDate,
Internal: false,
Artifacts: []portal.Artifact{
{Filename: "installer.tar"},
{Filename: "installer2.tar"},
},
},
{
Hash: "internalBuild",
Internal: true,
},
},
})
})
})
Context("Internal packages are included", func() {
BeforeEach(func() {
internal = true
})
It("marks internal packages with a *", func() {
mockTableWriter.EXPECT().AppendRow(
table.Row{"", "1.42", buildDate, "externalBuild", "installer.tar, installer2.tar"},
)
mockTableWriter.EXPECT().AppendRow(
table.Row{"*", "master", buildDate, "internalBuild", "installer.tar, installer2.tar"},
)
c.PrintPackagesTable(
portal.CodesphereBuilds{
Builds: []portal.CodesphereBuild{
{
Hash: "externalBuild",
Version: "1.42",
Date: buildDate,
Internal: false,
Artifacts: []portal.Artifact{
{Filename: "installer.tar"},
{Filename: "installer2.tar"},
},
},
{
Hash: "internalBuild",
Version: "master",
Date: buildDate,
Internal: true,
Artifacts: []portal.Artifact{
{Filename: "installer.tar"},
{Filename: "installer2.tar"},
},
},
},
})
})
})
})