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
40778f3d
Commit
40778f3d
authored
Mar 04, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #22194 from chbatey/testify-for-aws-provider
Auto commit by PR queue bot
parents
0ff71861
aebd4c95
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
2 deletions
+30
-2
aws_test.go
pkg/cloudprovider/providers/aws/aws_test.go
+30
-2
No files found.
pkg/cloudprovider/providers/aws/aws_test.go
View file @
40778f3d
...
@@ -30,7 +30,11 @@ import (
...
@@ -30,7 +30,11 @@ import (
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
)
const
TestClusterId
=
"clusterid.test"
const
TestClusterId
=
"clusterid.test"
...
@@ -257,6 +261,7 @@ type FakeEC2 struct {
...
@@ -257,6 +261,7 @@ type FakeEC2 struct {
DescribeSubnetsInput
*
ec2
.
DescribeSubnetsInput
DescribeSubnetsInput
*
ec2
.
DescribeSubnetsInput
RouteTables
[]
*
ec2
.
RouteTable
RouteTables
[]
*
ec2
.
RouteTable
DescribeRouteTablesInput
*
ec2
.
DescribeRouteTablesInput
DescribeRouteTablesInput
*
ec2
.
DescribeRouteTablesInput
mock
.
Mock
}
}
func
contains
(
haystack
[]
*
string
,
needle
string
)
bool
{
func
contains
(
haystack
[]
*
string
,
needle
string
)
bool
{
...
@@ -376,8 +381,9 @@ func (ec2 *FakeEC2) DetachVolume(request *ec2.DetachVolumeInput) (resp *ec2.Volu
...
@@ -376,8 +381,9 @@ func (ec2 *FakeEC2) DetachVolume(request *ec2.DetachVolumeInput) (resp *ec2.Volu
panic
(
"Not implemented"
)
panic
(
"Not implemented"
)
}
}
func
(
ec2
*
FakeEC2
)
DescribeVolumes
(
request
*
ec2
.
DescribeVolumesInput
)
([]
*
ec2
.
Volume
,
error
)
{
func
(
e
*
FakeEC2
)
DescribeVolumes
(
request
*
ec2
.
DescribeVolumesInput
)
([]
*
ec2
.
Volume
,
error
)
{
panic
(
"Not implemented"
)
args
:=
e
.
Called
(
request
)
return
args
.
Get
(
0
)
.
([]
*
ec2
.
Volume
),
nil
}
}
func
(
ec2
*
FakeEC2
)
CreateVolume
(
request
*
ec2
.
CreateVolumeInput
)
(
resp
*
ec2
.
Volume
,
err
error
)
{
func
(
ec2
*
FakeEC2
)
CreateVolume
(
request
*
ec2
.
CreateVolumeInput
)
(
resp
*
ec2
.
Volume
,
err
error
)
{
...
@@ -1161,3 +1167,25 @@ func TestFindInstancesByNodeName(t *testing.T) {
...
@@ -1161,3 +1167,25 @@ func TestFindInstancesByNodeName(t *testing.T) {
t
.
Errorf
(
"Expected node name %v but got %v"
,
nodeNameOne
,
returnedInstances
[
0
]
.
PrivateDnsName
)
t
.
Errorf
(
"Expected node name %v but got %v"
,
nodeNameOne
,
returnedInstances
[
0
]
.
PrivateDnsName
)
}
}
}
}
func
TestGetVolumeLabels
(
t
*
testing
.
T
)
{
awsServices
:=
NewFakeAWSServices
()
c
,
err
:=
newAWSCloud
(
strings
.
NewReader
(
"[global]"
),
awsServices
)
assert
.
Nil
(
t
,
err
,
"Error building aws cloud: %v"
,
err
)
volumeId
:=
aws
.
String
(
"vol-VolumeId"
)
expectedVolumeRequest
:=
&
ec2
.
DescribeVolumesInput
{
VolumeIds
:
[]
*
string
{
volumeId
}}
awsServices
.
ec2
.
On
(
"DescribeVolumes"
,
expectedVolumeRequest
)
.
Return
([]
*
ec2
.
Volume
{
{
VolumeId
:
volumeId
,
AvailabilityZone
:
&
awsServices
.
availabilityZone
,
},
})
labels
,
err
:=
c
.
GetVolumeLabels
(
*
volumeId
)
assert
.
Nil
(
t
,
err
,
"Error creating Volume %v"
,
err
)
assert
.
Equal
(
t
,
map
[
string
]
string
{
unversioned
.
LabelZoneFailureDomain
:
"us-east-1a"
,
unversioned
.
LabelZoneRegion
:
"us-east-1"
},
labels
)
awsServices
.
ec2
.
AssertExpectations
(
t
)
}
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