Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
7472adff
Commit
7472adff
authored
Jan 19, 2017
by
Derek McQuay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubeadm: skip tests if binary not present
Will skip integration tests for token generation if it can't find a file by the given --kubeadm-path or default value.
parent
16f45aee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
+15
-4
token_test.go
cmd/kubeadm/test/token_test.go
+15
-4
No files found.
cmd/kubeadm/test/token_test.go
View file @
7472adff
...
...
@@ -28,14 +28,21 @@ const (
TokenExpectedRegex
=
"^
\\
S{6}
\\
:
\\
S{16}
\n
$"
)
var
kubeadmPath
string
var
kubeadmPath
=
flag
.
String
(
"kubeadm-path"
,
filepath
.
Join
(
os
.
Getenv
(
"KUBE_ROOT"
),
"cluster/kubeadm.sh"
),
"Location of kubeadm"
)
var
testCmd
=
true
func
init
()
{
flag
.
StringVar
(
&
kubeadmPath
,
"kubeadm-path"
,
filepath
.
Join
(
os
.
Getenv
(
"KUBE_ROOT"
),
"cluster/kubeadm.sh"
),
"Location of kubeadm"
)
if
_
,
err
:=
os
.
Stat
(
*
kubeadmPath
);
os
.
IsNotExist
(
err
)
{
testCmd
=
false
}
}
func
TestCmdTokenGenerate
(
t
*
testing
.
T
)
{
stdout
,
_
,
err
:=
RunCmd
(
kubeadmPath
,
"ex"
,
"token"
,
"generate"
)
if
!
testCmd
{
t
.
Log
(
"kubeadm not found, skipping"
)
t
.
Skip
()
}
stdout
,
_
,
err
:=
RunCmd
(
*
kubeadmPath
,
"ex"
,
"token"
,
"generate"
)
if
err
!=
nil
{
t
.
Fatalf
(
"'kubeadm ex token generate' exited uncleanly: %v"
,
err
)
}
...
...
@@ -59,8 +66,12 @@ func TestCmdTokenGenerateTypoError(t *testing.T) {
with a non-zero status code after showing the command's usage, so that
the usage itself isn't captured as a token without the user noticing.
*/
if
!
testCmd
{
t
.
Log
(
"kubeadm not found, skipping"
)
t
.
Skip
()
}
_
,
_
,
err
:=
RunCmd
(
kubeadmPath
,
"ex"
,
"token"
,
"genorate"
)
// subtle typo
_
,
_
,
err
:=
RunCmd
(
*
kubeadmPath
,
"ex"
,
"token"
,
"genorate"
)
// subtle typo
if
err
==
nil
{
t
.
Error
(
"'kubeadm ex token genorate' (a deliberate typo) exited without an error when we expected non-zero exit status"
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment