Skip to content

Commit

Permalink
Loosen Operation Existence during Model Loading (#4804)
Browse files Browse the repository at this point in the history
* loosen operation existence for pagination

* loosen operation existence for waiters

* loosen operation existence for smoke tests
  • Loading branch information
Steven Yuan authored Apr 19, 2023
1 parent b9f8967 commit 23cb465
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
9 changes: 4 additions & 5 deletions private/model/api/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func (p *paginationDefinitions) setup() error {
if e.InputTokens == nil || e.OutputTokens == nil {
continue
}
if _, ok := p.Operations[n]; !ok {
continue
}
paginator := e

switch t := paginator.InputTokens.(type) {
Expand All @@ -83,11 +86,7 @@ func (p *paginationDefinitions) setup() error {
paginator.OutputTokens = toks
}

if o, ok := p.Operations[n]; ok {
o.Paginator = &paginator
} else {
return fmt.Errorf("unknown operation for paginator, %s", n)
}
p.Operations[n].Paginator = &paginator
}

return nil
Expand Down
2 changes: 2 additions & 0 deletions private/model/api/smoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ func (a *API) APISmokeTestsGoCode() string {
var smokeTestTmpl = template.Must(template.New(`smokeTestTmpl`).Parse(`
{{- range $i, $testCase := $.TestCases }}
{{- $op := index $.API.Operations $testCase.OpName }}
{{- if $op }}
func TestInteg_{{ printf "%02d" $i }}_{{ $op.ExportedName }}(t *testing.T) {
ctx, cancelFn := context.WithTimeout(context.Background(), 5 *time.Second)
defer cancelFn()
Expand Down Expand Up @@ -206,5 +207,6 @@ var smokeTestTmpl = template.Must(template.New(`smokeTestTmpl`).Parse(`
}
{{- end }}
}
{{- end }}
{{- end }}
`))
3 changes: 1 addition & 2 deletions private/model/api/waiters.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ func (p *waiterDefinitions) setup() error {
e.OperationName = p.ExportableName(e.OperationName)
e.Operation = p.API.Operations[e.OperationName]
if e.Operation == nil {
return fmt.Errorf("unknown operation %s for waiter %s",
e.OperationName, n)
continue
}
p.API.Waiters = append(p.API.Waiters, e)
}
Expand Down

0 comments on commit 23cb465

Please sign in to comment.