@@ -3,13 +3,11 @@ package httpapi_test
33import (
44 "context"
55 "encoding/json"
6- "fmt"
76 "io"
87 "log/slog"
98 "net/http"
109 "net/http/httptest"
1110 "os"
12- "sort"
1311 "testing"
1412
1513 "github.com/coder/agentapi/lib/httpapi"
@@ -19,28 +17,6 @@ import (
1917 "github.com/stretchr/testify/require"
2018)
2119
22- func normalizeSchema (t * testing.T , schema any ) any {
23- t .Helper ()
24- switch val := (schema ).(type ) {
25- case * any :
26- normalizeSchema (t , * val )
27- case []any :
28- for i := range val {
29- normalizeSchema (t , & val [i ])
30- }
31- sort .SliceStable (val , func (i , j int ) bool {
32- return fmt .Sprintf ("%v" , val [i ]) < fmt .Sprintf ("%v" , val [j ])
33- })
34- case map [string ]any :
35- for k := range val {
36- valUnderKey := val [k ]
37- normalizeSchema (t , & valUnderKey )
38- val [k ] = valUnderKey
39- }
40- }
41- return schema
42- }
43-
4420// Ensure the OpenAPI schema on disk is up to date.
4521// To update the schema, run `go run main.go server --print-openapi dummy > openapi.json`.
4622func TestOpenAPISchema (t * testing.T ) {
@@ -79,9 +55,6 @@ func TestOpenAPISchema(t *testing.T) {
7955 t .Fatalf ("failed to unmarshal disk schema: %s" , err )
8056 }
8157
82- normalizeSchema (t , & currentSchema )
83- normalizeSchema (t , & diskSchema )
84-
8558 require .Equal (t , currentSchema , diskSchema )
8659}
8760
0 commit comments