MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / TestDetect_LargeJSONNotOpenAPI

Function TestDetect_LargeJSONNotOpenAPI

internal/urlimport/detect_test.go:198–215  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

196}
197
198func TestDetect_LargeJSONNotOpenAPI(t *testing.T) {
199 // A huge JSON document that is not an OpenAPI spec must stay generic.
200 var b strings.Builder
201 b.WriteString(`{"name":"big","items":[`)
202 for i := 0; i < 5000; i++ {
203 if i > 0 {
204 b.WriteByte(',')
205 }
206 b.WriteString(`{"id":`)
207 b.WriteString(strings.Repeat("9", 20))
208 b.WriteString(`,"value":"x"}`)
209 }
210 b.WriteString(`]}`)
211 body := []byte(b.String())
212 if got := Detect("application/json", body); got != TypeGeneric {
213 t.Fatalf("Detect = %q, want %q for large non-OpenAPI JSON", got, TypeGeneric)
214 }
215}
216
217func TestCanonicalMediaType(t *testing.T) {
218 tests := []struct {

Callers

nothing calls this directly

Calls 2

DetectFunction · 0.85
StringMethod · 0.80

Tested by

no test coverage detected