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

Function TestTranslateYAMLMessage

pkg/parser/yaml_error_test.go:245–301  ·  view source on GitHub ↗

TestTranslateYAMLMessage tests the exported TranslateYAMLMessage function used by both the parser and workflow packages.

(t *testing.T)

Source from the content-addressed store, hash-verified

243// TestTranslateYAMLMessage tests the exported TranslateYAMLMessage function used
244// by both the parser and workflow packages.
245func TestTranslateYAMLMessage(t *testing.T) {
246 tests := []struct {
247 name string
248 input string
249 contains string
250 excludes string
251 }{
252 {
253 name: "unexpected key name",
254 input: "unexpected key name",
255 contains: "missing ':' after key",
256 excludes: "unexpected key name",
257 },
258 {
259 name: "non-map value is specified",
260 input: "non-map value is specified",
261 contains: "expected a YAML mapping",
262 excludes: "non-map value is specified",
263 },
264 {
265 name: "mapping value not found",
266 input: "yaml: mapping value not found",
267 contains: "missing ':' after key",
268 excludes: "mapping value not found",
269 },
270 {
271 name: "found character that cannot start any token",
272 input: "found character that cannot start any token",
273 contains: "invalid character",
274 excludes: "found character that cannot start any token",
275 },
276 {
277 name: "unrecognized message is unchanged",
278 input: "some other error",
279 contains: "some other error",
280 },
281 {
282 name: "empty string is unchanged",
283 input: "",
284 contains: "",
285 },
286 }
287
288 for _, tt := range tests {
289 t.Run(tt.name, func(t *testing.T) {
290 result := TranslateYAMLMessage(tt.input)
291 if tt.contains != "" {
292 assert.Contains(t, result, tt.contains,
293 "TranslateYAMLMessage should contain %q\nResult: %s", tt.contains, result)
294 }
295 if tt.excludes != "" {
296 assert.NotContains(t, result, tt.excludes,
297 "TranslateYAMLMessage should not contain %q\nResult: %s", tt.excludes, result)
298 }
299 })
300 }
301}
302

Callers

nothing calls this directly

Calls 2

TranslateYAMLMessageFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected