(t *testing.T)
| 463 | } |
| 464 | |
| 465 | func TestBuildChatOptionsWithImageParameters(t *testing.T) { |
| 466 | dir := t.TempDir() |
| 467 | t.Run("Valid image parameters should pass", func(t *testing.T) { |
| 468 | flags := &Flags{ |
| 469 | ImageFile: filepath.Join(dir, "test.png"), |
| 470 | ImageSize: "1024x1024", |
| 471 | ImageQuality: "high", |
| 472 | ImageBackground: "transparent", |
| 473 | ImageCompression: 0, // Not set for PNG |
| 474 | } |
| 475 | |
| 476 | options, err := flags.BuildChatOptions() |
| 477 | assert.NoError(t, err) |
| 478 | assert.NotNil(t, options) |
| 479 | assert.Equal(t, filepath.Join(dir, "test.png"), options.ImageFile) |
| 480 | assert.Equal(t, "1024x1024", options.ImageSize) |
| 481 | assert.Equal(t, "high", options.ImageQuality) |
| 482 | assert.Equal(t, "transparent", options.ImageBackground) |
| 483 | assert.Equal(t, 0, options.ImageCompression) |
| 484 | }) |
| 485 | |
| 486 | t.Run("Invalid image parameters should fail", func(t *testing.T) { |
| 487 | flags := &Flags{ |
| 488 | ImageFile: filepath.Join(dir, "test.png"), |
| 489 | ImageSize: "invalid", |
| 490 | ImageQuality: "high", |
| 491 | ImageBackground: "transparent", |
| 492 | } |
| 493 | |
| 494 | options, err := flags.BuildChatOptions() |
| 495 | assert.Error(t, err) |
| 496 | assert.Nil(t, options) |
| 497 | assert.Contains(t, err.Error(), "invalid image size") |
| 498 | }) |
| 499 | |
| 500 | t.Run("JPEG with compression should pass", func(t *testing.T) { |
| 501 | flags := &Flags{ |
| 502 | ImageFile: filepath.Join(dir, "test.jpg"), |
| 503 | ImageSize: "1536x1024", |
| 504 | ImageQuality: "medium", |
| 505 | ImageBackground: "opaque", |
| 506 | ImageCompression: 80, |
| 507 | } |
| 508 | |
| 509 | options, err := flags.BuildChatOptions() |
| 510 | assert.NoError(t, err) |
| 511 | assert.NotNil(t, options) |
| 512 | assert.Equal(t, 80, options.ImageCompression) |
| 513 | }) |
| 514 | |
| 515 | t.Run("Image parameters without image file should fail in BuildChatOptions", func(t *testing.T) { |
| 516 | flags := &Flags{ |
| 517 | ImageSize: "1024x1024", |
| 518 | } |
| 519 | |
| 520 | options, err := flags.BuildChatOptions() |
| 521 | assert.Error(t, err) |
| 522 | assert.Nil(t, options) |
nothing calls this directly
no test coverage detected