test: Add comprehensive testing infrastructure (Phase 2)#11
Merged
rianjs merged 10 commits intoopen-cli-collective:mainfrom Jan 11, 2026
Merged
Conversation
Add CI workflow that runs on every push to main and every PR: - Build and test job with race detection and coverage - Lint job using golangci-lint This establishes the foundation for validating all future changes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add .golangci.yml with standard linters: - errcheck, govet, ineffassign, staticcheck, unused, misspell - gofmt and goimports formatters with local prefix Fix lint issues found: - Replace fmt.Sscanf with strconv.ParseInt in formatTimestamp - Properly handle resp.Body.Close() errors using named returns - Fix import ordering with goimports Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add build-time version injection via ldflags: - VERSION from git describe - COMMIT from git rev-parse - DATE from current time Add new targets: - test-cover: Run tests with coverage report - test-short: Run quick tests - lint: Run golangci-lint - fmt: Run gofmt and goimports - deps: Download and tidy dependencies - verify: Verify go.mod Update build target to output to bin/ directory. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add version package with variables set via ldflags: - Version: semantic version from git tag - Commit: git commit hash - Date: build timestamp Includes Info() helper for formatted version string. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add version information to root command: - Set Version field from version package - Custom version template showing commit and build date Now `slack-cli --version` shows: slack-cli vX.Y.Z (commit: abc123, built: 2024-...) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Apply goimports formatting with local prefix to ensure consistent import ordering across all command files. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add NewWithConfig constructor for test injection with custom: - Base URL (for httptest servers) - Token - HTTP client Add 27 tests covering: - Client configuration and initialization - Channel operations (list, get, create, archive, unarchive, topic, purpose, invite) - User operations (list, get) - Message operations (send, update, delete, history, thread replies) - Reactions (add, remove) - Team info - Pagination handling - API error handling - Network error handling - Invalid JSON handling - Auth header verification All tests use httptest.NewServer for HTTP mocking. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add 12 tests covering: - GetAPIToken from environment variable - GetAPIToken when no token configured - IsSecureStorage platform detection - Config directory resolution (default and XDG_CONFIG_HOME) - Config file operations (set, get, delete) - Multiple keys handling - Key updates - File permissions (0600 for file, 0700 for directory) - Values containing equals signs Uses t.TempDir() and t.Setenv() for isolated testing. Skip keychain-dependent tests on macOS where appropriate. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for messages.go helper functions: - formatTimestamp: timestamp parsing and formatting - truncate: string truncation with newline handling - buildDefaultBlocks: Block Kit structure generation Add tests for command structure: - Verify messages command registration - Verify subcommands exist (send, update, delete, etc.) - Verify command aliases (msg, m) Uses table-driven tests with t.Run for clear test cases. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add comprehensive manual test documentation covering: - Test environment setup and prerequisites - Test data conventions - Command tests for all operations: - Configuration (set-token, show, delete-token) - Channels (list, get, create, archive, topic, invite) - Users (list, get) - Messages (send, update, delete, history, thread, react) - Workspace (info) - Edge cases and error scenarios - Pre-release test execution checklist - Troubleshooting guide Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is Phase 2 of the CLI guide alignment roadmap (Issue #2).
Note: This PR includes Phase 1 commits. Once PR #10 is merged, this can be rebased to show only Phase 2 changes.
Changes
API Client Tests (
internal/client/client_test.go)NewWithConfigconstructor for test injectionKeychain Tests (
internal/keychain/keychain_test.go)Command Tests (
cmd/messages_test.go)Integration Tests (
integration-tests.md)Test Coverage
Test plan
go test ./...golangci-lint runFixes #2
🤖 Generated with Claude Code