MCPcopy Create free account
hub / github.com/github/gh-aw / TestNormalizeForJSONSchema

Function TestNormalizeForJSONSchema

pkg/parser/schema_test.go:1220–1262  ·  view source on GitHub ↗

TestNormalizeForJSONSchema verifies that normalizeForJSONSchema correctly converts YAML-native integer types to float64 while leaving other types unchanged.

(t *testing.T)

Source from the content-addressed store, hash-verified

1218// TestNormalizeForJSONSchema verifies that normalizeForJSONSchema correctly converts
1219// YAML-native integer types to float64 while leaving other types unchanged.
1220func TestNormalizeForJSONSchema(t *testing.T) {
1221 tests := []struct {
1222 name string
1223 input any
1224 expected any
1225 }{
1226 // Integer type conversions
1227 {name: "int", input: int(42), expected: float64(42)},
1228 {name: "int8", input: int8(8), expected: float64(8)},
1229 {name: "int16", input: int16(16), expected: float64(16)},
1230 {name: "int32", input: int32(32), expected: float64(32)},
1231 {name: "int64", input: int64(64), expected: float64(64)},
1232 {name: "int64 negative", input: int64(-5), expected: float64(-5)},
1233
1234 // Unsigned integer type conversions
1235 {name: "uint", input: uint(42), expected: float64(42)},
1236 {name: "uint8", input: uint8(8), expected: float64(8)},
1237 {name: "uint16", input: uint16(16), expected: float64(16)},
1238 {name: "uint32", input: uint32(32), expected: float64(32)},
1239 {name: "uint64", input: uint64(64), expected: float64(64)},
1240 {name: "uint64 large", input: uint64(9999999999999), expected: float64(9999999999999)},
1241
1242 // Float type conversions
1243 {name: "float32", input: float32(3.14), expected: float64(float32(3.14))},
1244
1245 // Pass-through types
1246 {name: "float64 passthrough", input: float64(2.718), expected: float64(2.718)},
1247 {name: "string passthrough", input: "hello", expected: "hello"},
1248 {name: "bool true passthrough", input: true, expected: true},
1249 {name: "bool false passthrough", input: false, expected: false},
1250 {name: "nil passthrough", input: nil, expected: nil},
1251 }
1252
1253 for _, tt := range tests {
1254 t.Run(tt.name, func(t *testing.T) {
1255 result := normalizeForJSONSchema(tt.input)
1256 if result != tt.expected {
1257 t.Errorf("normalizeForJSONSchema(%T(%v)) = %T(%v), want %T(%v)",
1258 tt.input, tt.input, result, result, tt.expected, tt.expected)
1259 }
1260 })
1261 }
1262}
1263
1264func TestValidateMainWorkflowFrontmatterWithSchemaAndLocation_GitHubAppClientID(t *testing.T) {
1265 frontmatter := map[string]any{

Callers

nothing calls this directly

Calls 3

normalizeForJSONSchemaFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected