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
43be2d87
Commit
43be2d87
authored
Nov 29, 2016
by
NickrenREN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MetricsStatfs GetMetrics() function test
add test function to test GetMetrics() function in pkg/volume/metrics_statfs_test.go
parent
e6c57c65
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
0 deletions
+67
-0
BUILD
pkg/volume/BUILD
+2
-0
metrics_statfs_test.go
pkg/volume/metrics_statfs_test.go
+65
-0
No files found.
pkg/volume/BUILD
View file @
43be2d87
...
@@ -50,6 +50,7 @@ go_test(
...
@@ -50,6 +50,7 @@ go_test(
name = "go_default_test",
name = "go_default_test",
srcs = [
srcs = [
"metrics_nil_test.go",
"metrics_nil_test.go",
"metrics_statfs_test.go",
"plugins_test.go",
"plugins_test.go",
"util_test.go",
"util_test.go",
],
],
...
@@ -60,6 +61,7 @@ go_test(
...
@@ -60,6 +61,7 @@ go_test(
"//pkg/api/errors:go_default_library",
"//pkg/api/errors:go_default_library",
"//pkg/api/resource:go_default_library",
"//pkg/api/resource:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/util/testing:go_default_library",
"//pkg/watch:go_default_library",
"//pkg/watch:go_default_library",
],
],
)
)
...
...
pkg/volume/metrics_statfs_test.go
0 → 100644
View file @
43be2d87
/*
Copyright 2016 The Kubernetes Authors.
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
volume
import
(
"os"
"testing"
utiltesting
"k8s.io/kubernetes/pkg/util/testing"
)
func
TestGetMetricsStatFS
(
t
*
testing
.
T
)
{
metrics
:=
NewMetricsStatFS
(
""
)
actual
,
err
:=
metrics
.
GetMetrics
()
expected
:=
&
Metrics
{}
if
*
actual
!=
*
expected
{
t
.
Errorf
(
"Expected empty Metrics from uninitialized MetricsStatFS, actual %v"
,
*
actual
)
}
if
err
==
nil
{
t
.
Errorf
(
"Expected error when calling GetMetrics on uninitialized MetricsStatFS, actual nil"
)
}
metrics
=
NewMetricsStatFS
(
"/not/a/real/directory"
)
actual
,
err
=
metrics
.
GetMetrics
()
if
*
actual
!=
*
expected
{
t
.
Errorf
(
"Expected empty Metrics from incorrectly initialized MetricsStatFS, actual %v"
,
*
actual
)
}
if
err
==
nil
{
t
.
Errorf
(
"Expected error when calling GetMetrics on incorrectly initialized MetricsStatFS, actual nil"
)
}
tmpDir
,
err
:=
utiltesting
.
MkTmpdir
(
"metric_statfs_test"
)
if
err
!=
nil
{
t
.
Fatalf
(
"Can't make a tmp dir: %v"
,
err
)
}
defer
os
.
RemoveAll
(
tmpDir
)
metrics
=
NewMetricsStatFS
(
tmpDir
)
actual
,
err
=
metrics
.
GetMetrics
()
if
err
!=
nil
{
t
.
Errorf
(
"Unexpected error when calling GetMetrics %v"
,
err
)
}
if
a
:=
actual
.
Capacity
.
Value
();
a
<=
0
{
t
.
Errorf
(
"Expected Capacity %d to be greater than 0."
,
a
)
}
if
a
:=
actual
.
Available
.
Value
();
a
<=
0
{
t
.
Errorf
(
"Expected Available %d to be greater than 0."
,
a
)
}
}
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