feat: add CI/CD workflows, persistent chat, shell completions, and testing
- Add Gitea CI workflow for testing, linting, and building
- Add release workflow for multi-platform builds and GitHub releases
- Implement persistent chat history with JSON storage
- Add shell completion generation for bash, zsh, fish, powershell
- Introduce custom error types and logging system
- Add interfaces for git and AI client for better testability
- Enhance config with temperature and timeout settings
- Add comprehensive unit tests for config, errors, git, grok, and logger
- Update README with installation, features, and development instructions
- Make model flag persistent across commands
- Add context timeouts to API requests
2026-03-01 12:17:22 +00:00
|
|
|
package errors
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"errors"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestGitError(t *testing.T) {
|
|
|
|
|
baseErr := errors.New("command failed")
|
|
|
|
|
gitErr := &GitError{
|
|
|
|
|
Command: "status",
|
|
|
|
|
Err: baseErr,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
expected := "git status failed: command failed"
|
|
|
|
|
if gitErr.Error() != expected {
|
|
|
|
|
t.Errorf("GitError.Error() = %q, want %q", gitErr.Error(), expected)
|
|
|
|
|
}
|
|
|
|
|
|
chore(lint): enhance golangci configuration and add security annotations
- Expand .golangci.yml with more linters (bodyclose, errcheck, etc.), settings for govet, revive, gocritic, gosec
- Add // nolint:gosec comments for intentional file operations and subprocesses
- Change file write permissions from 0644 to 0600 for better security
- Refactor loops, error handling, and test parallelism with t.Parallel()
- Minor fixes: ignore unused args, use errors.Is, adjust mkdir permissions to 0750
2026-03-04 20:00:32 +00:00
|
|
|
if !errors.Is(gitErr, baseErr) {
|
|
|
|
|
t.Errorf("GitError did not wrap base error")
|
feat: add CI/CD workflows, persistent chat, shell completions, and testing
- Add Gitea CI workflow for testing, linting, and building
- Add release workflow for multi-platform builds and GitHub releases
- Implement persistent chat history with JSON storage
- Add shell completion generation for bash, zsh, fish, powershell
- Introduce custom error types and logging system
- Add interfaces for git and AI client for better testability
- Enhance config with temperature and timeout settings
- Add comprehensive unit tests for config, errors, git, grok, and logger
- Update README with installation, features, and development instructions
- Make model flag persistent across commands
- Add context timeouts to API requests
2026-03-01 12:17:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestAPIError(t *testing.T) {
|
|
|
|
|
tests := []struct {
|
|
|
|
|
name string
|
|
|
|
|
apiErr *APIError
|
|
|
|
|
expected string
|
|
|
|
|
shouldWrap bool
|
|
|
|
|
}{
|
|
|
|
|
{
|
|
|
|
|
name: "with status code",
|
|
|
|
|
apiErr: &APIError{
|
|
|
|
|
StatusCode: 404,
|
|
|
|
|
Message: "not found",
|
|
|
|
|
},
|
|
|
|
|
expected: "API error (status 404): not found",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "without status code",
|
|
|
|
|
apiErr: &APIError{
|
|
|
|
|
Message: "connection failed",
|
|
|
|
|
},
|
|
|
|
|
expected: "API error: connection failed",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, tt := range tests {
|
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
|
if tt.apiErr.Error() != tt.expected {
|
|
|
|
|
t.Errorf("APIError.Error() = %q, want %q", tt.apiErr.Error(), tt.expected)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestFileError(t *testing.T) {
|
|
|
|
|
baseErr := errors.New("permission denied")
|
|
|
|
|
fileErr := &FileError{
|
|
|
|
|
Path: "/tmp/test.txt",
|
|
|
|
|
Op: "read",
|
|
|
|
|
Err: baseErr,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
expected := "file read failed for /tmp/test.txt: permission denied"
|
|
|
|
|
if fileErr.Error() != expected {
|
|
|
|
|
t.Errorf("FileError.Error() = %q, want %q", fileErr.Error(), expected)
|
|
|
|
|
}
|
|
|
|
|
|
chore(lint): enhance golangci configuration and add security annotations
- Expand .golangci.yml with more linters (bodyclose, errcheck, etc.), settings for govet, revive, gocritic, gosec
- Add // nolint:gosec comments for intentional file operations and subprocesses
- Change file write permissions from 0644 to 0600 for better security
- Refactor loops, error handling, and test parallelism with t.Parallel()
- Minor fixes: ignore unused args, use errors.Is, adjust mkdir permissions to 0750
2026-03-04 20:00:32 +00:00
|
|
|
if !errors.Is(fileErr, baseErr) {
|
|
|
|
|
t.Errorf("FileError did not wrap base error")
|
feat: add CI/CD workflows, persistent chat, shell completions, and testing
- Add Gitea CI workflow for testing, linting, and building
- Add release workflow for multi-platform builds and GitHub releases
- Implement persistent chat history with JSON storage
- Add shell completion generation for bash, zsh, fish, powershell
- Introduce custom error types and logging system
- Add interfaces for git and AI client for better testability
- Enhance config with temperature and timeout settings
- Add comprehensive unit tests for config, errors, git, grok, and logger
- Update README with installation, features, and development instructions
- Make model flag persistent across commands
- Add context timeouts to API requests
2026-03-01 12:17:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
2026-03-02 22:12:54 +00:00
|
|
|
|
|
|
|
|
func TestAPIErrorUnwrap(t *testing.T) {
|
|
|
|
|
baseErr := errors.New("base api err")
|
|
|
|
|
apiErr := &APIError{
|
|
|
|
|
StatusCode: 500,
|
|
|
|
|
Message: "internal error",
|
|
|
|
|
Err: baseErr,
|
|
|
|
|
}
|
chore(lint): enhance golangci configuration and add security annotations
- Expand .golangci.yml with more linters (bodyclose, errcheck, etc.), settings for govet, revive, gocritic, gosec
- Add // nolint:gosec comments for intentional file operations and subprocesses
- Change file write permissions from 0644 to 0600 for better security
- Refactor loops, error handling, and test parallelism with t.Parallel()
- Minor fixes: ignore unused args, use errors.Is, adjust mkdir permissions to 0750
2026-03-04 20:00:32 +00:00
|
|
|
if !errors.Is(apiErr, baseErr) {
|
|
|
|
|
t.Errorf("APIError.Unwrap() = %v, want %v", apiErr.Unwrap(), baseErr)
|
2026-03-02 22:12:54 +00:00
|
|
|
}
|
|
|
|
|
}
|