Skip to content

Commit

Permalink
Merge pull request #6 from lalamove/fix-format-parsing
Browse files Browse the repository at this point in the history
Fix format parsing
  • Loading branch information
kyue1005 authored Jan 19, 2021
2 parents 627f6b3 + dabd772 commit effe6b5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/routes/apollo/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (a *Apollo) parseNamespace(namespace string) (string, string) {
ext := filepath.Ext(namespace)

switch ext {
case ".properties", ".yml", ".xml":
case ".properties", ".yml", ".yaml", ".xml", ".json":
s := strings.TrimSuffix(namespace, ext)
return s, ext
default:
Expand Down
32 changes: 32 additions & 0 deletions internal/routes/apollo/routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,38 @@ func TestParseNamespace(t *testing.T) {
)
})

t.Run("get ns2.yaml", func(t *testing.T) {
ns, ext := a.parseNamespace("ns2.yaml")
require.Equal(
t,
"ns2",
ns,
ns,
)
require.Equal(
t,
".yaml",
ext,
ext,
)
})

t.Run("get ns2.json", func(t *testing.T) {
ns, ext := a.parseNamespace("ns2.json")
require.Equal(
t,
"ns2",
ns,
ns,
)
require.Equal(
t,
".json",
ext,
ext,
)
})

t.Run("get ns", func(t *testing.T) {
ns, ext := a.parseNamespace("ns")
require.Equal(
Expand Down

0 comments on commit effe6b5

Please sign in to comment.