Skip to content

Commit

Permalink
Merge pull request #21 from Comcast/feature/format-enforcement
Browse files Browse the repository at this point in the history
Feature/format enforcement
  • Loading branch information
schmidtw authored Sep 27, 2017
2 parents 413680a + 6dc7dab commit 162d85b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
7 changes: 7 additions & 0 deletions .travis.gofmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if [ -n "$(gofmt -s -l .)" ]; then
echo "Go code is not formatted:"
gofmt -s -d -e .
exit 1
fi
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ before_install:
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then docker exec build bash -c "pushd codecovio_build; git fetch origin +refs/pull/${TRAVIS_PULL_REQUEST}/merge && git checkout -qf FETCH_HEAD; popd"; fi'

script:
- docker exec build bash -c "export GOPATH=/codecovio_build && pushd codecovio_build/src && glide install --strip-vendor && cd talaria && go build talaria && go test -race -coverprofile=coverage.txt && popd"
- docker exec build bash -c "export GOPATH=/codecovio_build && pushd codecovio_build/src && glide install --strip-vendor && cd talaria && go build talaria && go test -race -coverprofile=coverage.txt && ../../.travis.gofmt.sh && popd"
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker exec build bash -c "pushd talaria; ./build_rpm.sh; popd"; fi'

after_success:
Expand Down
24 changes: 12 additions & 12 deletions src/talaria/dispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,57 +72,57 @@ func testDispatcherOnDeviceEventDispatchEvent(t *testing.T) {
expectedEndpoints: map[string]bool{},
},
{
outbounder: &Outbounder{Method: "BADMETHOD&%*(!@(&%(", EventEndpoints: map[string][]string{"iot": []string{"http://endpoint1.com"}}},
outbounder: &Outbounder{Method: "BADMETHOD&%*(!@(&%(", EventEndpoints: map[string][]string{"iot": {"http://endpoint1.com"}}},
destination: "event:iot",
expectedEndpoints: map[string]bool{},
},
{
outbounder: &Outbounder{EventEndpoints: map[string][]string{"another": []string{"http://endpoint1.com"}}},
outbounder: &Outbounder{EventEndpoints: map[string][]string{"another": {"http://endpoint1.com"}}},
destination: "event:iot",
expectedEndpoints: map[string]bool{},
},
{
outbounder: &Outbounder{EventEndpoints: map[string][]string{"another": []string{"http://endpoint1.com"}}},
outbounder: &Outbounder{EventEndpoints: map[string][]string{"another": {"http://endpoint1.com"}}},
destination: "event:iot",
expectedEndpoints: map[string]bool{},
},
{
outbounder: &Outbounder{EventEndpoints: map[string][]string{"default": []string{"http://endpoint1.com"}}},
outbounder: &Outbounder{EventEndpoints: map[string][]string{"default": {"http://endpoint1.com"}}},
destination: "event:iot",
expectedEndpoints: map[string]bool{"http://endpoint1.com": true},
},
{
outbounder: &Outbounder{Method: "PATCH", EventEndpoints: map[string][]string{"default": []string{"http://endpoint1.com"}}},
outbounder: &Outbounder{Method: "PATCH", EventEndpoints: map[string][]string{"default": {"http://endpoint1.com"}}},
destination: "event:iot",
expectedEndpoints: map[string]bool{"http://endpoint1.com": true},
},
{
outbounder: &Outbounder{EventEndpoints: map[string][]string{"default": []string{"http://endpoint1.com", "http://endpoint2.com"}}},
outbounder: &Outbounder{EventEndpoints: map[string][]string{"default": {"http://endpoint1.com", "http://endpoint2.com"}}},
destination: "event:iot",
expectedEndpoints: map[string]bool{"http://endpoint1.com": true, "http://endpoint2.com": true},
},
{
outbounder: &Outbounder{Method: "PATCH", EventEndpoints: map[string][]string{"default": []string{"http://endpoint1.com", "http://endpoint2.com"}}},
outbounder: &Outbounder{Method: "PATCH", EventEndpoints: map[string][]string{"default": {"http://endpoint1.com", "http://endpoint2.com"}}},
destination: "event:iot",
expectedEndpoints: map[string]bool{"http://endpoint1.com": true, "http://endpoint2.com": true},
},
{
outbounder: &Outbounder{EventEndpoints: map[string][]string{"iot": []string{"http://endpoint1.com"}}},
outbounder: &Outbounder{EventEndpoints: map[string][]string{"iot": {"http://endpoint1.com"}}},
destination: "event:iot",
expectedEndpoints: map[string]bool{"http://endpoint1.com": true},
},
{
outbounder: &Outbounder{Method: "PATCH", EventEndpoints: map[string][]string{"iot": []string{"http://endpoint1.com"}}},
outbounder: &Outbounder{Method: "PATCH", EventEndpoints: map[string][]string{"iot": {"http://endpoint1.com"}}},
destination: "event:iot",
expectedEndpoints: map[string]bool{"http://endpoint1.com": true},
},
{
outbounder: &Outbounder{EventEndpoints: map[string][]string{"iot": []string{"http://endpoint1.com", "http://endpoint2.com"}}},
outbounder: &Outbounder{EventEndpoints: map[string][]string{"iot": {"http://endpoint1.com", "http://endpoint2.com"}}},
destination: "event:iot",
expectedEndpoints: map[string]bool{"http://endpoint1.com": true, "http://endpoint2.com": true},
},
{
outbounder: &Outbounder{Method: "PATCH", EventEndpoints: map[string][]string{"iot": []string{"http://endpoint1.com", "http://endpoint2.com"}}},
outbounder: &Outbounder{Method: "PATCH", EventEndpoints: map[string][]string{"iot": {"http://endpoint1.com", "http://endpoint2.com"}}},
destination: "event:iot",
expectedEndpoints: map[string]bool{"http://endpoint1.com": true, "http://endpoint2.com": true},
},
Expand Down Expand Up @@ -184,7 +184,7 @@ func testDispatcherOnDeviceEventEventTimeout(t *testing.T) {
require = require.New(t)
outbounder = &Outbounder{
RequestTimeout: 100 * time.Millisecond,
EventEndpoints: map[string][]string{"default": []string{"nowhere.com"}},
EventEndpoints: map[string][]string{"default": {"nowhere.com"}},
}

d, _, err = NewDispatcher(outbounder, nil)
Expand Down
4 changes: 2 additions & 2 deletions src/talaria/outbounder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ func testOutbounderConfiguration(t *testing.T) {
assert.Equal(map[string]bool{"nntp": true, "ftp": true}, o.allowedSchemes())
assert.Equal(
map[string][]string{
"iot": []string{"https://endpoint1.com", "https://endpoint2.com"},
"something": []string{"https://endpoint3.com"},
"iot": {"https://endpoint1.com", "https://endpoint2.com"},
"something": {"https://endpoint3.com"},
},
o.eventEndpoints(),
)
Expand Down

0 comments on commit 162d85b

Please sign in to comment.