-
Notifications
You must be signed in to change notification settings - Fork 613
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mux utils to ecs-agent and make target for running ecs-agent tests
- Loading branch information
Showing
47 changed files
with
19,522 additions
and
1 deletion.
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,34 @@ | ||
// copyright amazon.com inc. or its affiliates. all rights reserved. | ||
// | ||
// licensed under the apache license, version 2.0 (the "license"). you may | ||
// not use this file except in compliance with the license. a copy of the | ||
// license is located at | ||
// | ||
// http://aws.amazon.com/apache2.0/ | ||
// | ||
// or in the "license" file accompanying this file. this file 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 mux | ||
|
||
const ( | ||
// AnythingRegEx is a regex pattern that matches anything. | ||
AnythingRegEx = ".*" | ||
|
||
// AnythingButSlashRegEx is a regex pattern that matches any string without slash. | ||
AnythingButSlashRegEx = "[^/]*" | ||
|
||
// AnythingButEmptyRegEx is a regex pattern that matches anything but an empty string. | ||
AnythingButEmptyRegEx = ".+" | ||
) | ||
|
||
// ConstructMuxVar constructs the mux var that is used in the gorilla/mux styled | ||
// path, example: {id}, {id:[0-9]+}. | ||
func ConstructMuxVar(name string, pattern string) string { | ||
if pattern == "" { | ||
return "{" + name + "}" | ||
} | ||
|
||
return "{" + name + ":" + pattern + "}" | ||
} |
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,59 @@ | ||
//go:build unit | ||
// +build unit | ||
|
||
// copyright amazon.com inc. or its affiliates. all rights reserved. | ||
// | ||
// licensed under the apache license, version 2.0 (the "license"). you may | ||
// not use this file except in compliance with the license. a copy of the | ||
// license is located at | ||
// | ||
// http://aws.amazon.com/apache2.0/ | ||
// | ||
// or in the "license" file accompanying this file. this file 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 mux | ||
|
||
import "testing" | ||
import "github.com/stretchr/testify/assert" | ||
|
||
func TestConstructMuxVar(t *testing.T) { | ||
testCases := []struct { | ||
testName string | ||
name string | ||
pattern string | ||
expectedVar string | ||
}{ | ||
{ | ||
testName: "With anything but slash pattern", | ||
name: "muxname", | ||
pattern: AnythingButSlashRegEx, | ||
expectedVar: "{muxname:[^/]*}", | ||
}, | ||
{ | ||
testName: "With anything pattern", | ||
name: "muxname", | ||
pattern: AnythingRegEx, | ||
expectedVar: "{muxname:.*}", | ||
}, | ||
{ | ||
testName: "With anything but empty pattern", | ||
name: "muxname", | ||
pattern: AnythingButEmptyRegEx, | ||
expectedVar: "{muxname:.+}", | ||
}, | ||
{ | ||
testName: "Without pattern", | ||
name: "muxname", | ||
pattern: "", | ||
expectedVar: "{muxname}", | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.testName, func(t *testing.T) { | ||
assert.Equal(t, tc.expectedVar, ConstructMuxVar(tc.name, tc.pattern)) | ||
}) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
145 changes: 145 additions & 0 deletions
145
ecs-agent/vendor/github.com/davecgh/go-spew/spew/bypass.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
ecs-agent/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.