Skip to content

Commit

Permalink
dump function annotations in thrift files
Browse files Browse the repository at this point in the history
  • Loading branch information
2011aad committed Mar 25, 2024
1 parent 71e6c89 commit 6c02a36
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 6 additions & 1 deletion tool/trimmer/dump/dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ func TestDumpSingle(t *testing.T) {
filename := filepath.Join("..", "test_cases", "sample1.thrift")
ast, err := parser.ParseFile(filename, []string{"test_cases"}, true)
test.Assert(t, err == nil, err)
_, err = DumpIDL(ast)
out, err := DumpIDL(ast)
test.Assert(t, err == nil, err)

// tests for function annotations
test.Assert(t, strings.Contains(out, "api.get"), "output should contains function annotations")
test.Assert(t, strings.Contains(out, "api.post"), "output should contains function annotations")
test.Assert(t, strings.Contains(out, "api.put"), "output should contains function annotations")
}

func TestDumpMany(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions tool/trimmer/dump/field_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ const FunctionTemplate = `
{{- if $index}},{{end -}}{{- template "SingleLineField" .}}
{{- end}})
{{- end}}
{{- template "Annotations" .Annotations -}}
{{- end -}}
`

Expand Down
9 changes: 4 additions & 5 deletions tool/trimmer/test_cases/sample1.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,13 @@ service EmployeeService extends sample1b.GetPerson {
service ProjectService {
Project getProject(1: string id)
oneway void addProject(1: Project project)
void updateProject(1: string id,
2: Project project)
void updateProject(1: string id, 2: Project project)
}

service CompanyService {
Company getCompany(1: string id)
void addCompany(1: Company company) throws(1: samlpe1bAnotherException exc)
void updateCompany(1: string id, 2: Company company)
Company getCompany(1: string id) (api.get = "/company")
void addCompany(1: Company company) throws(1: samlpe1bAnotherException exc) (api.put = "/company")
void updateCompany(1: string id, 2: Company company) (api.post = "/company")
list<sample1b.Department> getDepartments(1: string company_id)
void anotherUselessMethod(1: MaybeUseless useless)
}
Expand Down

0 comments on commit 6c02a36

Please sign in to comment.