Skip to content

Comments

test: add command-level validation tests, move validation before client creation#132

Merged
omriariav merged 1 commit intomainfrom
fix/add-command-level-tests
Feb 19, 2026
Merged

test: add command-level validation tests, move validation before client creation#132
omriariav merged 1 commit intomainfrom
fix/add-command-level-tests

Conversation

@omriariav
Copy link
Owner

Summary

Addresses the systemic test gap identified across all 7 post-merge reviews: _MockServer tests don't exercise run* functions.

New validation tests (cmd/validation_test.go):

  • Forms: --file + --title conflict guard, no-flags error
  • Sheets: --value required for 7 conditional format rule types, negative --index rejection
  • Slides: invalid --size rejection
  • Contacts: update with no field flags error

Production code improvement — moved flag validation before client.NewFactory() in:

  • runFormsUpdate
  • runSheetsAddConditionalFormat
  • runSheetsDeleteConditionalFormat
  • runSlidesThumbnail
  • runContactsUpdate

This makes validation errors fire before OAuth credential checks, improving UX (faster, clearer errors) and making the code testable without mock servers.

Test plan

  • go vet ./... clean
  • go test ./... all pass (12 new test cases)
  • All pre-existing tests still pass

🤖 Generated with Claude Code

…nt creation

Add validation_test.go with tests that exercise run* functions through
Cobra commands, catching validation errors before any API call:
- Forms: --file + --title conflict, no-flags error
- Sheets: --value required for conditional format rules, negative --index
- Slides: invalid --size rejection
- Contacts: update with no field flags

Move flag validation before client.NewFactory() in all affected commands
so validation errors fire before OAuth credential checks. This improves
UX (faster, clearer errors) and makes the validations testable without
a mock server.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@omriariav omriariav merged commit f8974a2 into main Feb 19, 2026
1 check passed
@omriariav omriariav deleted the fix/add-command-level-tests branch February 19, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant