Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
7112a48a
Unverified
Commit
7112a48a
authored
Jul 14, 2017
by
Adam Reese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ref(helm): refactor cleanup of environment after tests run
parent
a29e6109
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
76 additions
and
71 deletions
+76
-71
create_test.go
cmd/helm/create_test.go
+4
-3
dependency_build_test.go
cmd/helm/dependency_build_test.go
+4
-3
dependency_update_test.go
cmd/helm/dependency_update_test.go
+8
-8
fetch_test.go
cmd/helm/fetch_test.go
+4
-3
helm_test.go
cmd/helm/helm_test.go
+14
-7
init_test.go
cmd/helm/init_test.go
+4
-3
package_test.go
cmd/helm/package_test.go
+4
-3
plugin_test.go
cmd/helm/plugin_test.go
+10
-24
repo_add_test.go
cmd/helm/repo_add_test.go
+8
-6
repo_remove_test.go
cmd/helm/repo_remove_test.go
+4
-3
repo_update_test.go
cmd/helm/repo_update_test.go
+9
-6
search_test.go
cmd/helm/search_test.go
+3
-2
No files found.
cmd/helm/create_test.go
View file @
7112a48a
...
...
@@ -85,13 +85,14 @@ func TestCreateStarterCmd(t *testing.T) {
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
old
:=
settings
.
Home
settings
.
Home
=
thome
cleanup
:=
resetEnv
()
defer
func
()
{
settings
.
Home
=
old
os
.
RemoveAll
(
thome
.
String
())
cleanup
()
}()
settings
.
Home
=
thome
// Create a starter.
starterchart
:=
filepath
.
Join
(
thome
.
String
(),
"starters"
)
os
.
Mkdir
(
starterchart
,
0755
)
...
...
cmd/helm/dependency_build_test.go
View file @
7112a48a
...
...
@@ -29,17 +29,18 @@ import (
)
func
TestDependencyBuildCmd
(
t
*
testing
.
T
)
{
oldhome
:=
settings
.
Home
hh
,
err
:=
tempHelmHome
(
t
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
settings
.
Home
=
hh
cleanup
:=
resetEnv
()
defer
func
()
{
os
.
RemoveAll
(
hh
.
String
())
settings
.
Home
=
oldhome
cleanup
()
}()
settings
.
Home
=
hh
srv
:=
repotest
.
NewServer
(
hh
.
String
())
defer
srv
.
Stop
()
_
,
err
=
srv
.
CopyCharts
(
"testdata/testcharts/*.tgz"
)
...
...
cmd/helm/dependency_update_test.go
View file @
7112a48a
...
...
@@ -34,18 +34,18 @@ import (
)
func
TestDependencyUpdateCmd
(
t
*
testing
.
T
)
{
// Set up a testing helm home
oldhome
:=
settings
.
Home
hh
,
err
:=
tempHelmHome
(
t
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
settings
.
Home
=
hh
cleanup
:=
resetEnv
()
defer
func
()
{
os
.
RemoveAll
(
hh
.
String
())
settings
.
Home
=
oldhome
cleanup
()
}()
settings
.
Home
=
hh
srv
:=
repotest
.
NewServer
(
hh
.
String
())
defer
srv
.
Stop
()
copied
,
err
:=
srv
.
CopyCharts
(
"testdata/testcharts/*.tgz"
)
...
...
@@ -129,18 +129,18 @@ func TestDependencyUpdateCmd(t *testing.T) {
}
func
TestDependencyUpdateCmd_SkipRefresh
(
t
*
testing
.
T
)
{
// Set up a testing helm home
oldhome
:=
settings
.
Home
hh
,
err
:=
tempHelmHome
(
t
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
settings
.
Home
=
hh
cleanup
:=
resetEnv
()
defer
func
()
{
os
.
RemoveAll
(
hh
.
String
())
settings
.
Home
=
oldhome
cleanup
()
}()
settings
.
Home
=
hh
srv
:=
repotest
.
NewServer
(
hh
.
String
())
defer
srv
.
Stop
()
copied
,
err
:=
srv
.
CopyCharts
(
"testdata/testcharts/*.tgz"
)
...
...
cmd/helm/fetch_test.go
View file @
7112a48a
...
...
@@ -32,15 +32,16 @@ func TestFetchCmd(t *testing.T) {
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
old
:=
settings
.
Home
settings
.
Home
=
hh
cleanup
:=
resetEnv
()
defer
func
()
{
settings
.
Home
=
old
os
.
RemoveAll
(
hh
.
String
())
cleanup
()
}()
srv
:=
repotest
.
NewServer
(
hh
.
String
())
defer
srv
.
Stop
()
settings
.
Home
=
hh
// all flags will get "--home=TMDIR -d outdir" appended.
tests
:=
[]
struct
{
name
string
...
...
cmd/helm/helm_test.go
View file @
7112a48a
...
...
@@ -233,13 +233,8 @@ func ensureTestHome(home helmpath.Home, t *testing.T) error {
}
func
TestRootCmd
(
t
*
testing
.
T
)
{
// reset env
defer
func
(
origEnv
[]
string
)
{
for
_
,
pair
:=
range
origEnv
{
kv
:=
strings
.
SplitN
(
pair
,
"="
,
2
)
os
.
Setenv
(
kv
[
0
],
kv
[
1
])
}
}(
os
.
Environ
())
cleanup
:=
resetEnv
()
defer
cleanup
()
tests
:=
[]
struct
{
name
string
...
...
@@ -312,3 +307,15 @@ func TestRootCmd(t *testing.T) {
})
}
}
func
resetEnv
()
func
()
{
origSettings
:=
settings
origEnv
:=
os
.
Environ
()
return
func
()
{
settings
=
origSettings
for
_
,
pair
:=
range
origEnv
{
kv
:=
strings
.
SplitN
(
pair
,
"="
,
2
)
os
.
Setenv
(
kv
[
0
],
kv
[
1
])
}
}
}
cmd/helm/init_test.go
View file @
7112a48a
...
...
@@ -140,13 +140,14 @@ func TestInitCmd_dryRun(t *testing.T) {
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
dbg
:=
settings
.
Debug
settings
.
Debug
=
true
cleanup
:=
resetEnv
()
defer
func
()
{
os
.
Remove
(
home
)
settings
.
Debug
=
dbg
cleanup
()
}()
settings
.
Debug
=
true
var
buf
bytes
.
Buffer
fc
:=
fake
.
NewSimpleClientset
()
cmd
:=
&
initCmd
{
...
...
cmd/helm/package_test.go
View file @
7112a48a
...
...
@@ -143,14 +143,15 @@ func TestPackage(t *testing.T) {
}
ensureTestHome
(
helmpath
.
Home
(
tmp
),
t
)
oldhome
:=
settings
.
Home
settings
.
Home
=
helmpath
.
Home
(
tmp
)
cleanup
:=
resetEnv
()
defer
func
()
{
settings
.
Home
=
oldhome
os
.
Chdir
(
origDir
)
os
.
RemoveAll
(
tmp
)
cleanup
()
}()
settings
.
Home
=
helmpath
.
Home
(
tmp
)
for
_
,
tt
:=
range
tests
{
buf
:=
bytes
.
NewBuffer
(
nil
)
c
:=
newPackageCmd
(
buf
)
...
...
cmd/helm/plugin_test.go
View file @
7112a48a
...
...
@@ -63,25 +63,13 @@ func TestManuallyProcessArgs(t *testing.T) {
}
// resetEnv sets an env var, and returns a defer function to reset the env
func
resetEnv
(
name
,
val
string
)
func
()
{
original
,
ok
:=
os
.
LookupEnv
(
name
)
os
.
Setenv
(
name
,
val
)
if
ok
{
return
func
()
{
os
.
Setenv
(
name
,
original
)
}
}
return
func
()
{
os
.
Unsetenv
(
name
)
}
}
func
TestLoadPlugins
(
t
*
testing
.
T
)
{
// Set helm home to point to testdata
old
:=
settings
.
Home
cleanup
:=
resetEnv
()
defer
cleanup
()
settings
.
Home
=
"testdata/helmhome"
cleanup
:=
resetEnv
(
"HELM_HOME"
,
settings
.
Home
.
String
())
defer
func
()
{
settings
.
Home
=
old
cleanup
()
}()
os
.
Setenv
(
"HELM_HOME"
,
settings
.
Home
.
String
())
hh
:=
settings
.
Home
out
:=
bytes
.
NewBuffer
(
nil
)
...
...
@@ -148,14 +136,12 @@ func TestLoadPlugins(t *testing.T) {
}
func
TestLoadPlugins_HelmNoPlugins
(
t
*
testing
.
T
)
{
// Set helm home to point to testdata
old
:=
settings
.
Home
cleanup
:=
resetEnv
()
defer
cleanup
()
settings
.
Home
=
"testdata/helmhome"
cleanup
:=
resetEnv
(
"HELM_NO_PLUGINS"
,
"1"
)
defer
func
()
{
settings
.
Home
=
old
cleanup
()
}()
os
.
Setenv
(
"HELM_NO_PLUGINS"
,
"1"
)
out
:=
bytes
.
NewBuffer
(
nil
)
cmd
:=
&
cobra
.
Command
{}
...
...
cmd/helm/repo_add_test.go
View file @
7112a48a
...
...
@@ -33,17 +33,18 @@ func TestRepoAddCmd(t *testing.T) {
t
.
Fatal
(
err
)
}
oldhome
:=
settings
.
Home
settings
.
Home
=
thome
cleanup
:=
resetEnv
()
defer
func
()
{
srv
.
Stop
()
settings
.
Home
=
oldhome
os
.
Remove
(
thome
.
String
())
cleanup
()
}()
if
err
:=
ensureTestHome
(
thome
,
t
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
settings
.
Home
=
thome
tests
:=
[]
releaseCase
{
{
name
:
"add a repository"
,
...
...
@@ -67,18 +68,19 @@ func TestRepoAdd(t *testing.T) {
t
.
Fatal
(
err
)
}
oldhome
:=
settings
.
Home
settings
.
Home
=
thome
cleanup
:=
resetEnv
()
hh
:=
thome
defer
func
()
{
ts
.
Stop
()
settings
.
Home
=
oldhome
os
.
Remove
(
thome
.
String
())
cleanup
()
}()
if
err
:=
ensureTestHome
(
hh
,
t
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
settings
.
Home
=
thome
if
err
:=
addRepository
(
testName
,
ts
.
URL
(),
hh
,
""
,
""
,
""
,
true
);
err
!=
nil
{
t
.
Error
(
err
)
}
...
...
cmd/helm/repo_remove_test.go
View file @
7112a48a
...
...
@@ -33,18 +33,19 @@ func TestRepoRemove(t *testing.T) {
t
.
Fatal
(
err
)
}
oldhome
:=
settings
.
Home
settings
.
Home
=
thome
hh
:=
helmpath
.
Home
(
thome
)
cleanup
:=
resetEnv
()
defer
func
()
{
ts
.
Stop
()
settings
.
Home
=
oldhome
os
.
Remove
(
thome
.
String
())
cleanup
()
}()
if
err
:=
ensureTestHome
(
hh
,
t
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
settings
.
Home
=
thome
b
:=
bytes
.
NewBuffer
(
nil
)
if
err
:=
removeRepoLine
(
b
,
testName
,
hh
);
err
==
nil
{
...
...
cmd/helm/repo_update_test.go
View file @
7112a48a
...
...
@@ -34,13 +34,15 @@ func TestUpdateCmd(t *testing.T) {
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
oldhome
:=
settings
.
Home
settings
.
Home
=
thome
cleanup
:=
resetEnv
()
defer
func
()
{
settings
.
Home
=
oldhome
os
.
Remove
(
thome
.
String
())
cleanup
()
}()
settings
.
Home
=
thome
out
:=
bytes
.
NewBuffer
(
nil
)
// Instead of using the HTTP updater, we provide our own for this test.
// The TestUpdateCharts test verifies the HTTP behavior independently.
...
...
@@ -69,18 +71,19 @@ func TestUpdateCharts(t *testing.T) {
t
.
Fatal
(
err
)
}
oldhome
:=
settings
.
Home
settings
.
Home
=
thome
hh
:=
helmpath
.
Home
(
thome
)
cleanup
:=
resetEnv
()
defer
func
()
{
ts
.
Stop
()
settings
.
Home
=
oldhome
os
.
Remove
(
thome
.
String
())
cleanup
()
}()
if
err
:=
ensureTestHome
(
hh
,
t
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
settings
.
Home
=
thome
r
,
err
:=
repo
.
NewChartRepository
(
&
repo
.
Entry
{
Name
:
"charts"
,
URL
:
ts
.
URL
(),
...
...
cmd/helm/search_test.go
View file @
7112a48a
...
...
@@ -68,9 +68,10 @@ func TestSearchCmd(t *testing.T) {
},
}
oldhome
:=
settings
.
Home
cleanup
:=
resetEnv
()
defer
cleanup
()
settings
.
Home
=
"testdata/helmhome"
defer
func
()
{
settings
.
Home
=
oldhome
}()
for
_
,
tt
:=
range
tests
{
buf
:=
bytes
.
NewBuffer
(
nil
)
...
...
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