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
f28db5a8
Commit
f28db5a8
authored
Jan 23, 2018
by
Brendan Burns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some more azure unit tests.
parent
5b9ba2f6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
1 deletion
+85
-1
BUILD
pkg/cloudprovider/providers/azure/BUILD
+2
-0
azure_fakes.go
pkg/cloudprovider/providers/azure/azure_fakes.go
+3
-1
azure_storageaccount_test.go
...loudprovider/providers/azure/azure_storageaccount_test.go
+80
-0
No files found.
pkg/cloudprovider/providers/azure/BUILD
View file @
f28db5a8
...
...
@@ -69,6 +69,7 @@ go_test(
"azure_loadbalancer_test.go",
"azure_metrics_test.go",
"azure_standard_test.go",
"azure_storageaccount_test.go",
"azure_test.go",
"azure_vmss_test.go",
"azure_wrap_test.go",
...
...
@@ -81,6 +82,7 @@ go_test(
"//pkg/kubelet/apis: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/storage:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
...
...
pkg/cloudprovider/providers/azure/azure_fakes.go
View file @
f28db5a8
...
...
@@ -930,6 +930,8 @@ func (fRTC *fakeRouteTablesClient) Get(resourceGroupName string, routeTableName
type
fakeStorageAccountClient
struct
{
mutex
*
sync
.
Mutex
FakeStore
map
[
string
]
map
[
string
]
storage
.
Account
Keys
storage
.
AccountListKeysResult
Err
error
}
func
newFakeStorageAccountClient
()
*
fakeStorageAccountClient
{
...
...
@@ -999,7 +1001,7 @@ func (fSAC *fakeStorageAccountClient) Delete(resourceGroupName string, accountNa
}
func
(
fSAC
*
fakeStorageAccountClient
)
ListKeys
(
resourceGroupName
string
,
accountName
string
)
(
result
storage
.
AccountListKeysResult
,
err
error
)
{
return
storage
.
AccountListKeysResult
{},
nil
return
fSAC
.
Keys
,
fSAC
.
Err
}
func
(
fSAC
*
fakeStorageAccountClient
)
ListByResourceGroup
(
resourceGroupName
string
)
(
result
storage
.
AccountListResult
,
err
error
)
{
...
...
pkg/cloudprovider/providers/azure/azure_storageaccount_test.go
0 → 100644
View file @
f28db5a8
/*
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/Azure/azure-sdk-for-go/arm/storage"
)
func
TestGetStorageAccessKeys
(
t
*
testing
.
T
)
{
cloud
:=
&
Cloud
{}
fake
:=
newFakeStorageAccountClient
()
cloud
.
StorageAccountClient
=
fake
value
:=
"foo bar"
tests
:=
[]
struct
{
results
storage
.
AccountListKeysResult
expectedKey
string
expectErr
bool
err
error
}{
{
storage
.
AccountListKeysResult
{},
""
,
true
,
nil
},
{
storage
.
AccountListKeysResult
{
Keys
:
&
[]
storage
.
AccountKey
{
{
Value
:
&
value
},
},
},
"bar"
,
false
,
nil
,
},
{
storage
.
AccountListKeysResult
{
Keys
:
&
[]
storage
.
AccountKey
{
{},
{
Value
:
&
value
},
},
},
"bar"
,
false
,
nil
,
},
{
storage
.
AccountListKeysResult
{},
""
,
true
,
fmt
.
Errorf
(
"test error"
)},
}
for
_
,
test
:=
range
tests
{
expectedKey
:=
test
.
expectedKey
fake
.
Keys
=
test
.
results
fake
.
Err
=
test
.
err
key
,
err
:=
cloud
.
getStorageAccesskey
(
"acct"
)
if
test
.
expectErr
&&
err
==
nil
{
t
.
Errorf
(
"Unexpected non-error"
)
continue
}
if
!
test
.
expectErr
&&
err
!=
nil
{
t
.
Errorf
(
"Unexpected error: %v"
,
err
)
continue
}
if
key
!=
expectedKey
{
t
.
Errorf
(
"expected: %s, saw %s"
,
expectedKey
,
key
)
}
}
}
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