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
f55d87ab
Commit
f55d87ab
authored
Feb 26, 2019
by
Jingfang Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix the failed test
parent
beacc87e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
6 deletions
+91
-6
builder_test.go
...li-runtime/pkg/genericclioptions/resource/builder_test.go
+91
-6
No files found.
staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/builder_test.go
View file @
f55d87ab
...
@@ -569,7 +569,93 @@ func TestDirectoryBuilder(t *testing.T) {
...
@@ -569,7 +569,93 @@ func TestDirectoryBuilder(t *testing.T) {
}
}
}
}
func
setupKustomizeDirectory
()
(
string
,
error
)
{
path
,
err
:=
ioutil
.
TempDir
(
"/tmp"
,
""
)
if
err
!=
nil
{
return
""
,
err
}
contents
:=
map
[
string
]
string
{
"configmap.yaml"
:
`
apiVersion: v1
kind: ConfigMap
metadata:
name: the-map
data:
altGreeting: "Good Morning!"
enableRisky: "false"
`
,
"deployment.yaml"
:
`
apiVersion: apps/v1
kind: Deployment
metadata:
name: the-deployment
spec:
replicas: 3
template:
metadata:
labels:
deployment: hello
spec:
containers:
- name: the-container
image: monopole/hello:1
command: ["/hello",
"--port=8080",
"--enableRiskyFeature=$(ENABLE_RISKY)"]
ports:
- containerPort: 8080
env:
- name: ALT_GREETING
valueFrom:
configMapKeyRef:
name: the-map
key: altGreeting
- name: ENABLE_RISKY
valueFrom:
configMapKeyRef:
name: the-map
key: enableRisky
`
,
"service.yaml"
:
`
kind: Service
apiVersion: v1
metadata:
name: the-service
spec:
selector:
deployment: hello
type: LoadBalancer
ports:
- protocol: TCP
port: 8666
targetPort: 8080
`
,
"kustomization.yaml"
:
`
nameprefix: test-
resources:
- deployment.yaml
- service.yaml
- configmap.yaml
`
,
}
for
filename
,
content
:=
range
contents
{
err
=
ioutil
.
WriteFile
(
filepath
.
Join
(
path
,
filename
),
[]
byte
(
content
),
0660
)
if
err
!=
nil
{
return
""
,
err
}
}
return
path
,
nil
}
func
TestKustomizeDirectoryBuilder
(
t
*
testing
.
T
)
{
func
TestKustomizeDirectoryBuilder
(
t
*
testing
.
T
)
{
dir
,
err
:=
setupKustomizeDirectory
()
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error %v"
,
err
)
}
defer
os
.
RemoveAll
(
dir
)
tests
:=
[]
struct
{
tests
:=
[]
struct
{
directory
string
directory
string
expectErr
bool
expectErr
bool
...
@@ -582,12 +668,11 @@ func TestKustomizeDirectoryBuilder(t *testing.T) {
...
@@ -582,12 +668,11 @@ func TestKustomizeDirectoryBuilder(t *testing.T) {
expectErr
:
true
,
expectErr
:
true
,
errMsg
:
"No kustomization file found"
,
errMsg
:
"No kustomization file found"
,
},
},
// TODO(Liujingfang1): Fix this test in bazel test
{
//{
directory
:
dir
,
// directory: "../../../artifacts/kustomization",
expectErr
:
false
,
// expectErr: false,
expectedNames
:
[]
string
{
"test-the-map"
,
"test-the-deployment"
,
"test-the-service"
},
// expectedNames: []string{"test-the-map", "test-the-deployment", "test-the-service"},
},
//},
{
{
directory
:
"../../../artifacts/kustomization/should-not-load.yaml"
,
directory
:
"../../../artifacts/kustomization/should-not-load.yaml"
,
expectErr
:
true
,
expectErr
:
true
,
...
...
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