Commit ac2d595 1 parent a28c285 commit ac2d595 Copy full SHA for ac2d595
File tree 2 files changed +56
-0
lines changed
2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -462,6 +462,10 @@ func (d *deployer) pollUntilComplete(
462
462
func getOutputs (
463
463
deployment * resourcesSDK.DeploymentExtended ,
464
464
) (map [string ]interface {}, error ) {
465
+ // Check if deployment output is nil as "outputs" section/element is optional in ARM template.
466
+ if deployment .Properties .Outputs == nil {
467
+ return map [string ]interface {}{}, nil
468
+ }
465
469
outputs , ok := deployment .Properties .Outputs .(map [string ]interface {})
466
470
if ! ok {
467
471
return nil , errors .New ("error decoding deployment outputs" )
Original file line number Diff line number Diff line change
1
+ package templates
2
+
3
+ import (
4
+ "testing"
5
+
6
+ resourcesSDK "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources"
7
+ "github.com/stretchr/testify/assert"
8
+ )
9
+
10
+ func TestGetOutputs_ValidOutputs (t * testing.T ) {
11
+ deployment := & resourcesSDK.DeploymentExtended {
12
+ Properties : & resourcesSDK.DeploymentPropertiesExtended {
13
+ Outputs : map [string ]interface {}{
14
+ "output1" : map [string ]interface {}{
15
+ "value" : "amaterasu" ,
16
+ },
17
+ "output2" : map [string ]interface {}{
18
+ "value" : 108 ,
19
+ },
20
+ },
21
+ },
22
+ }
23
+
24
+ outputs , err := getOutputs (deployment )
25
+ assert .NoError (t , err )
26
+ assert .Equal (t , "amaterasu" , outputs ["output1" ])
27
+ assert .Equal (t , 108 , outputs ["output2" ])
28
+ }
29
+
30
+ func TestGetOutputs_InvalidOutputs (t * testing.T ) {
31
+ deployment := & resourcesSDK.DeploymentExtended {
32
+ Properties : & resourcesSDK.DeploymentPropertiesExtended {
33
+ Outputs : "invalid" ,
34
+ },
35
+ }
36
+
37
+ outputs , err := getOutputs (deployment )
38
+ assert .Error (t , err )
39
+ assert .Nil (t , outputs )
40
+ }
41
+
42
+ func TestGetOutputs_NoOutputs (t * testing.T ) {
43
+ deployment := & resourcesSDK.DeploymentExtended {
44
+ Properties : & resourcesSDK.DeploymentPropertiesExtended {
45
+ Outputs : nil ,
46
+ },
47
+ }
48
+
49
+ outputs , err := getOutputs (deployment )
50
+ assert .NoError (t , err )
51
+ assert .Empty (t , outputs )
52
+ }
You can’t perform that action at this time.
0 commit comments