-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(service): add generic webhook service (#144)
* feat(format): improve default props handling this makes it possible to ignore errors setting config props and defaults * feat(service): add generic webhook service * docs(generic): add some basic docs * test(format): add and split additional tests * docs: fix broken markdown formatting
- Loading branch information
Showing
13 changed files
with
966 additions
and
269 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
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,48 @@ | ||
package format | ||
|
||
import ( | ||
"net/url" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Query Formatter", func() { | ||
var pkr PropKeyResolver | ||
BeforeEach(func() { | ||
ts = &testStruct{} | ||
pkr = NewPropKeyResolver(ts) | ||
_ = pkr.SetDefaultProps(ts) | ||
}) | ||
Describe("Creating a service URL query from a config", func() { | ||
When("a config property has been changed from default", func() { | ||
It("should be included in the query string", func() { | ||
ts.Str = "test" | ||
query := BuildQuery(&pkr) | ||
// (pkr, ) | ||
Expect(query).To(Equal("str=test")) | ||
}) | ||
}) | ||
When("a custom query key conflicts with a config property key", func() { | ||
It("should include both values, with the custom escaped", func() { | ||
ts.Str = "service" | ||
customQuery := url.Values{"str": {"custom"}} | ||
query := BuildQueryWithCustomFields(&pkr, customQuery) | ||
Expect(query.Encode()).To(Equal("__str=custom&str=service")) | ||
}) | ||
}) | ||
}) | ||
Describe("Setting prop values from query", func() { | ||
When("a custom query key conflicts with a config property key", func() { | ||
It("should set the config prop from the regular and return the custom one unescaped", func() { | ||
ts.Str = "service" | ||
serviceQuery := url.Values{"__str": {"custom"}, "str": {"service"}} | ||
query, err := SetConfigPropsFromQuery(&pkr, serviceQuery) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(ts.Str).To(Equal("service")) | ||
Expect(query.Get("str")).To(Equal("custom")) | ||
}) | ||
}) | ||
}) | ||
|
||
}) |
Oops, something went wrong.