MCPcopy
hub / github.com/danielmiessler/Fabric / TestBuildChatOptionsWithImageParameters

Function TestBuildChatOptionsWithImageParameters

internal/cli/flags_test.go:397–457  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

395}
396
397func TestBuildChatOptionsWithImageParameters(t *testing.T) {
398 t.Run("Valid image parameters should pass", func(t *testing.T) {
399 flags := &Flags{
400 ImageFile: "/tmp/test.png",
401 ImageSize: "1024x1024",
402 ImageQuality: "high",
403 ImageBackground: "transparent",
404 ImageCompression: 0, // Not set for PNG
405 }
406
407 options, err := flags.BuildChatOptions()
408 assert.NoError(t, err)
409 assert.NotNil(t, options)
410 assert.Equal(t, "/tmp/test.png", options.ImageFile)
411 assert.Equal(t, "1024x1024", options.ImageSize)
412 assert.Equal(t, "high", options.ImageQuality)
413 assert.Equal(t, "transparent", options.ImageBackground)
414 assert.Equal(t, 0, options.ImageCompression)
415 })
416
417 t.Run("Invalid image parameters should fail", func(t *testing.T) {
418 flags := &Flags{
419 ImageFile: "/tmp/test.png",
420 ImageSize: "invalid",
421 ImageQuality: "high",
422 ImageBackground: "transparent",
423 }
424
425 options, err := flags.BuildChatOptions()
426 assert.Error(t, err)
427 assert.Nil(t, options)
428 assert.Contains(t, err.Error(), "invalid image size")
429 })
430
431 t.Run("JPEG with compression should pass", func(t *testing.T) {
432 flags := &Flags{
433 ImageFile: "/tmp/test.jpg",
434 ImageSize: "1536x1024",
435 ImageQuality: "medium",
436 ImageBackground: "opaque",
437 ImageCompression: 80,
438 }
439
440 options, err := flags.BuildChatOptions()
441 assert.NoError(t, err)
442 assert.NotNil(t, options)
443 assert.Equal(t, 80, options.ImageCompression)
444 })
445
446 t.Run("Image parameters without image file should fail in BuildChatOptions", func(t *testing.T) {
447 flags := &Flags{
448 ImageSize: "1024x1024", // Image parameter without ImageFile
449 }
450
451 options, err := flags.BuildChatOptions()
452 assert.Error(t, err)
453 assert.Nil(t, options)
454 assert.Contains(t, err.Error(), "image parameters")

Callers

nothing calls this directly

Calls 2

BuildChatOptionsMethod · 0.95
ErrorMethod · 0.80

Tested by

no test coverage detected