-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make group, vnet, and nsg services async
- Loading branch information
Cecile Robert-Michon
committed
Aug 31, 2021
1 parent
2179e72
commit f5bf49b
Showing
73 changed files
with
2,803 additions
and
1,184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
Copyright 2021 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 converters | ||
|
||
import ( | ||
"testing" | ||
|
||
azureautorest "github.com/Azure/go-autorest/autorest/azure" | ||
"github.com/onsi/gomega" | ||
|
||
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha4" | ||
) | ||
|
||
var ( | ||
validFuture = infrav1.Future{ | ||
Type: infrav1.DeleteFuture, | ||
ServiceName: "test-service", | ||
Name: "test-group", | ||
ResourceGroup: "test-group", | ||
Data: "eyJtZXRob2QiOiJERUxFVEUiLCJwb2xsaW5nTWV0aG9kIjoiTG9jYXRpb24iLCJscm9TdGF0ZSI6IkluUHJvZ3Jlc3MifQ==", | ||
} | ||
|
||
emptyDataFuture = infrav1.Future{ | ||
Type: infrav1.DeleteFuture, | ||
ServiceName: "test-service", | ||
Name: "test-group", | ||
ResourceGroup: "test-group", | ||
Data: "", | ||
} | ||
|
||
decodedDataFuture = infrav1.Future{ | ||
Type: infrav1.DeleteFuture, | ||
ServiceName: "test-service", | ||
Name: "test-group", | ||
ResourceGroup: "test-group", | ||
Data: "this is not b64 encoded", | ||
} | ||
|
||
invalidFuture = infrav1.Future{ | ||
Type: infrav1.DeleteFuture, | ||
ServiceName: "test-service", | ||
Name: "test-group", | ||
ResourceGroup: "test-group", | ||
Data: "ZmFrZSBiNjQgZnV0dXJlIGRhdGEK", | ||
} | ||
) | ||
|
||
func Test_FutureToSDK(t *testing.T) { | ||
cases := []struct { | ||
name string | ||
future infrav1.Future | ||
expect func(*gomega.GomegaWithT, azureautorest.FutureAPI, error) | ||
}{ | ||
{ | ||
name: "data is empty", | ||
future: emptyDataFuture, | ||
expect: func(g *gomega.GomegaWithT, f azureautorest.FutureAPI, err error) { | ||
g.Expect(err.Error()).Should(gomega.ContainSubstring("failed to unmarshal future data")) | ||
}, | ||
}, | ||
{ | ||
name: "data is not base64 encoded", | ||
future: decodedDataFuture, | ||
expect: func(g *gomega.GomegaWithT, f azureautorest.FutureAPI, err error) { | ||
g.Expect(err.Error()).Should(gomega.ContainSubstring("failed to base64 decode future data")) | ||
}, | ||
}, | ||
{ | ||
name: "base64 data is not a valid future", | ||
future: invalidFuture, | ||
expect: func(g *gomega.GomegaWithT, f azureautorest.FutureAPI, err error) { | ||
g.Expect(err.Error()).Should(gomega.ContainSubstring("failed to unmarshal future data")) | ||
}, | ||
}, | ||
{ | ||
name: "valid future data", | ||
future: validFuture, | ||
expect: func(g *gomega.GomegaWithT, f azureautorest.FutureAPI, err error) { | ||
g.Expect(err).Should(gomega.BeNil()) | ||
g.Expect(f).Should(gomega.BeAssignableToTypeOf(&azureautorest.Future{})) | ||
}, | ||
}, | ||
} | ||
|
||
for _, c := range cases { | ||
c := c | ||
t.Run(c.name, func(t *testing.T) { | ||
t.Parallel() | ||
g := gomega.NewGomegaWithT(t) | ||
result, err := FutureToSDK(c.future) | ||
c.expect(g, result, err) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.