Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
openwow
/
kubevirt-actions-runner
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security
Insights
Files
cdb9f5b
.github
ci
cmd/kar
app
app_suite_test.go
flag.go
opts.go
root.go
root_test.go
main.go
internal
scripts
.gitignore
.golangci.yml
.spellcheck.yml
Dockerfile
Makefile
README.md
go.mod
go.sum
tox.ini
Breadcrumbs
kubevirt-actions-runner
/
cmd
/
kar
/
app
/
root_test.go
Blame
Blame
Latest commit
History
History
114 lines (91 loc) · 2.76 KB
Breadcrumbs
kubevirt-actions-runner
/
cmd
/
kar
/
app
/
root_test.go
Top
File metadata and controls
Code
Blame
114 lines (91 loc) · 2.76 KB
Raw
/* Copyright © 2023 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package app_test import ( "context" "slices" "github.com/electrocucaracha/kubevirt-actions-runner/cmd/kar/app" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/spf13/cobra" ) type mock struct { failed bool createCalled bool waitCalled bool deleteCalled bool vmTemplate string runnerName string jitConfig string } func (m *mock) Failed() bool { return m.failed } func (m *mock) GetVMIName() string { return m.runnerName } func (m *mock) GetDataVolumeName() string { return m.runnerName } func (m *mock) CreateResources(_ context.Context, vmTemplate, runnerName, jitConfig string, ) error { m.vmTemplate = vmTemplate m.runnerName = runnerName m.jitConfig = jitConfig m.createCalled = true return nil } func (m *mock) WaitForVirtualMachineInstance(_ context.Context) { m.waitCalled = true } func (m *mock) DeleteResources(_ context.Context, _, _ string) error { m.deleteCalled = true return nil } var _ = Describe("Root Command", func() { var runner mock var cmd *cobra.Command var opts app.Opts BeforeEach(func() { runner = mock{} cmd = app.NewRootCommand(context.TODO(), &runner, opts) }) DescribeTable("initialization process", func(shouldSucceed, failed bool, args ...string) { cmd.SetArgs(args) runner.failed = failed err := cmd.Execute() if shouldSucceed { Expect(err).NotTo(HaveOccurred()) } else { Expect(err).To(HaveOccurred()) } if slices.Contains(args, "-c") { Expect(runner.jitConfig).To(Equal(args[slices.Index(args, "-c")+1])) } if slices.Contains(args, "-r") { Expect(runner.runnerName).To(Equal(args[slices.Index(args, "-r")+1])) } if slices.Contains(args, "-t") { Expect(runner.vmTemplate).To(Equal(args[slices.Index(args, "-t")+1])) } Expect(runner.createCalled).Should(BeTrue()) Expect(runner.deleteCalled).Should(BeTrue()) Expect(runner.waitCalled).Should(BeTrue()) }, Entry("when the default options are provided", true, false), Entry("when config option is provided", true, false, "-c", "test config"), Entry("when vm template option is provided", true, false, "-t", "vm template"), Entry("when runner name option is provided", true, false, "-r", "runner name"), Entry("when the execution failed", false, true), ) })
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
106
107
108
109
110
111
112
113
114
You can’t perform that action at this time.