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
924f9a45
Commit
924f9a45
authored
Nov 21, 2017
by
Pengfei Ni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add fake clients and unit tests
parent
65c0738a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
1 deletion
+63
-1
BUILD
pkg/cloudprovider/providers/azure/BUILD
+6
-1
azure_fakes.go
pkg/cloudprovider/providers/azure/azure_fakes.go
+4
-0
azure_util_test.go
pkg/cloudprovider/providers/azure/azure_util_test.go
+53
-0
No files found.
pkg/cloudprovider/providers/azure/BUILD
View file @
924f9a45
...
@@ -23,6 +23,7 @@ go_library(
...
@@ -23,6 +23,7 @@ go_library(
"azure_storage.go",
"azure_storage.go",
"azure_storageaccount.go",
"azure_storageaccount.go",
"azure_util.go",
"azure_util.go",
"azure_util_vmss.go",
"azure_wrap.go",
"azure_wrap.go",
"azure_zones.go",
"azure_zones.go",
],
],
...
@@ -57,7 +58,10 @@ go_library(
...
@@ -57,7 +58,10 @@ go_library(
go_test(
go_test(
name = "go_default_test",
name = "go_default_test",
srcs = ["azure_test.go"],
srcs = [
"azure_test.go",
"azure_util_test.go",
],
importpath = "k8s.io/kubernetes/pkg/cloudprovider/providers/azure",
importpath = "k8s.io/kubernetes/pkg/cloudprovider/providers/azure",
library = ":go_default_library",
library = ":go_default_library",
deps = [
deps = [
...
@@ -66,6 +70,7 @@ go_test(
...
@@ -66,6 +70,7 @@ go_test(
"//vendor/github.com/Azure/azure-sdk-for-go/arm/compute:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/arm/compute:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/arm/network:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/arm/network:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
...
...
pkg/cloudprovider/providers/azure/azure_fakes.go
View file @
924f9a45
...
@@ -339,6 +339,10 @@ func (fIC fakeAzureInterfacesClient) Get(resourceGroupName string, networkInterf
...
@@ -339,6 +339,10 @@ func (fIC fakeAzureInterfacesClient) Get(resourceGroupName string, networkInterf
}
}
}
}
func
(
fIC
fakeAzureInterfacesClient
)
GetVirtualMachineScaleSetNetworkInterface
(
resourceGroupName
string
,
virtualMachineScaleSetName
string
,
virtualmachineIndex
string
,
networkInterfaceName
string
,
expand
string
)
(
result
network
.
Interface
,
err
error
)
{
return
result
,
nil
}
type
fakeAzureVirtualMachinesClient
struct
{
type
fakeAzureVirtualMachinesClient
struct
{
mutex
*
sync
.
Mutex
mutex
*
sync
.
Mutex
FakeStore
map
[
string
]
map
[
string
]
compute
.
VirtualMachine
FakeStore
map
[
string
]
map
[
string
]
compute
.
VirtualMachine
...
...
pkg/cloudprovider/providers/azure/azure_util_test.go
0 → 100644
View file @
924f9a45
/*
Copyright 2017 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
azure
import
(
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func
TestGetVmssInstanceID
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
msg
string
machineName
string
expectError
bool
expectedInstanceID
string
}{{
msg
:
"invalid vmss instance name"
,
machineName
:
"vmvm"
,
expectError
:
true
,
},
{
msg
:
"valid vmss instance name"
,
machineName
:
"vm00000Z"
,
expectError
:
false
,
expectedInstanceID
:
"35"
,
},
}
for
i
,
test
:=
range
tests
{
instanceID
,
err
:=
getVmssInstanceID
(
test
.
machineName
)
if
test
.
expectError
{
assert
.
Error
(
t
,
err
,
fmt
.
Sprintf
(
"TestCase[%d]: %s"
,
i
,
test
.
msg
))
}
else
{
assert
.
Equal
(
t
,
test
.
expectedInstanceID
,
instanceID
,
fmt
.
Sprintf
(
"TestCase[%d]: %s"
,
i
,
test
.
msg
))
}
}
}
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