refactor(cmd/api): remove redundant sdk spec slice helper
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
8a23545a67
commit
30e610686b
2 changed files with 11 additions and 10 deletions
|
|
@ -150,14 +150,6 @@ func sdkSpecBuilder(title, description, version, swaggerPath, graphqlPath string
|
|||
}
|
||||
}
|
||||
|
||||
func sdkSpecGroups() []goapi.RouteGroup {
|
||||
groups := make([]goapi.RouteGroup, 0)
|
||||
for group := range sdkSpecGroupsIter() {
|
||||
groups = append(groups, group)
|
||||
}
|
||||
return groups
|
||||
}
|
||||
|
||||
func sdkSpecGroupsIter() iter.Seq[goapi.RouteGroup] {
|
||||
return specGroupsIter(goapi.NewToolBridge("/tools"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ package api
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"iter"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
|
|
@ -34,6 +35,14 @@ func (specCmdStubGroup) Describe() []api.RouteDescription {
|
|||
}
|
||||
}
|
||||
|
||||
func collectRouteGroups(groups iter.Seq[api.RouteGroup]) []api.RouteGroup {
|
||||
out := make([]api.RouteGroup, 0)
|
||||
for group := range groups {
|
||||
out = append(out, group)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func TestAPISpecCmd_Good_CommandStructure(t *testing.T) {
|
||||
root := &cli.Command{Use: "root"}
|
||||
AddAPICommands(root)
|
||||
|
|
@ -717,7 +726,7 @@ func TestAPISDKCmd_Good_TempSpecUsesMetadataFlags(t *testing.T) {
|
|||
"",
|
||||
"https://api.example.com, /, https://api.example.com",
|
||||
)
|
||||
groups := sdkSpecGroups()
|
||||
groups := collectRouteGroups(sdkSpecGroupsIter())
|
||||
|
||||
outputFile := t.TempDir() + "/spec.json"
|
||||
if err := api.ExportSpecToFile(outputFile, "json", builder, groups); err != nil {
|
||||
|
|
@ -828,7 +837,7 @@ func TestAPISDKCmd_Good_SpecGroupsDeduplicateToolBridge(t *testing.T) {
|
|||
|
||||
api.RegisterSpecGroups(api.NewToolBridge("/tools"))
|
||||
|
||||
groups := sdkSpecGroups()
|
||||
groups := collectRouteGroups(sdkSpecGroupsIter())
|
||||
if len(groups) != 1 {
|
||||
t.Fatalf("expected the built-in tools bridge to be deduplicated, got %d groups", len(groups))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue