-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/default-to-https
- Loading branch information
Showing
11 changed files
with
744 additions
and
266 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
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,19 @@ | ||
package openapi | ||
|
||
import "fmt" | ||
|
||
type parentResourceInfo struct { | ||
parentResourceNames []string | ||
fullParentResourceName string | ||
parentURIs []string | ||
parentInstanceURIs []string | ||
} | ||
|
||
// getParentPropertiesNames is responsible to building the parent properties names for a resource that is a subresource | ||
func (info *parentResourceInfo) getParentPropertiesNames() []string { | ||
parentPropertyNames := []string{} | ||
for _, parentName := range info.parentResourceNames { | ||
parentPropertyNames = append(parentPropertyNames, fmt.Sprintf("%s_id", parentName)) | ||
} | ||
return parentPropertyNames | ||
} |
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,45 @@ | ||
package openapi | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/smartystreets/goconvey/convey" | ||
) | ||
|
||
func Test_getParentPropertiesNames(t *testing.T) { | ||
Convey("Given an empty parentResourceInfo", t, func() { | ||
s := &parentResourceInfo{} | ||
Convey("When the method getParentPropertiesNames is called", func() { | ||
p := s.getParentPropertiesNames() | ||
Convey("Then array returned should be empty", func() { | ||
So(p, ShouldBeEmpty) | ||
}) | ||
}) | ||
}) | ||
|
||
Convey("Given a parentResourceInfo with empty parentResourceNames", t, func() { | ||
s := &parentResourceInfo{ | ||
parentResourceNames: []string{}, | ||
} | ||
Convey("When the method getParentPropertiesNames is called", func() { | ||
p := s.getParentPropertiesNames() | ||
Convey("Then array returned should be empty", func() { | ||
So(p, ShouldBeEmpty) | ||
}) | ||
}) | ||
}) | ||
|
||
Convey("Given a parentResourceInfo with some parentResourceNames", t, func() { | ||
s := &parentResourceInfo{ | ||
parentResourceNames: []string{"cdn_v1", "cdn_v1_firewalls_v2"}, | ||
} | ||
Convey("When the method getParentPropertiesNames is called", func() { | ||
p := s.getParentPropertiesNames() | ||
Convey("And the array returned should contain the expected parent names including the id postfix", func() { | ||
So(len(p), ShouldEqual, 2) | ||
So(p[0], ShouldEqual, "cdn_v1_id") | ||
So(p[1], ShouldEqual, "cdn_v1_firewalls_v2_id") | ||
}) | ||
}) | ||
}) | ||
} |
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.