diff options
| author | mo khan <mo@mokhan.ca> | 2026-01-30 17:18:31 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2026-01-30 17:18:31 -0700 |
| commit | e4ed0342932b0aa741ee78d9e4fe135eba6e9ca7 (patch) | |
| tree | f1e7f602cb86e78aedf04185b2c2e1428fc5b8f2 /pkg/git/utils_test.go | |
| parent | 83be9ddcf82e8a90ea50a9d54c1ebfc3e22ace16 (diff) | |
initial commit
Diffstat (limited to 'pkg/git/utils_test.go')
| -rw-r--r-- | pkg/git/utils_test.go | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/pkg/git/utils_test.go b/pkg/git/utils_test.go deleted file mode 100644 index 4dcebe8..0000000 --- a/pkg/git/utils_test.go +++ /dev/null @@ -1,80 +0,0 @@ -package git_test - -import ( - "strings" - "testing" - - "github.com/antonmedv/gitmal/pkg/git" -) - -func TestParseFileMode(t *testing.T) { - tests := []struct { - mode string - expected string - }{ - {"100644", "rw-r--r--"}, - {"100755", "rwxr-xr-x"}, - {"100600", "rw-------"}, - {"100400", "r--------"}, - } - - for _, tt := range tests { - t.Run(tt.mode, func(t *testing.T) { - result, err := git.ParseFileMode(tt.mode) - if err != nil { - t.Errorf("unexpected error: %v", err) - } - if result != tt.expected { - t.Errorf("got %q, want %q", result, tt.expected) - } - }) - } -} - -func TestParseFileModeInvalid(t *testing.T) { - tests := []string{ - "", - "12", - "abc", - "10070x", - } - - for _, mode := range tests { - t.Run(mode, func(t *testing.T) { - result, err := git.ParseFileMode(mode) - if err == nil { - t.Error("expected error, got nil") - } - if result != "" { - t.Errorf("expected empty result, got %q", result) - } - if !strings.Contains(err.Error(), "invalid mode") && !strings.Contains(err.Error(), "strconv.Atoi") { - t.Errorf("unexpected error message: %v", err) - } - }) - } -} - -func TestRefToFileName(t *testing.T) { - tests := []struct { - in string - want string - }{ - {"main", "main"}, - {"master", "master"}, - {"release/v1.0", "release-v1.0"}, - {"feature/add-login", "feature-add-login"}, - {"bugfix\\windows\\path", "bugfix-windows-path"}, - {"1.0.0", "1.0.0"}, - {"1.x", "1.x"}, - } - - for _, tt := range tests { - t.Run(tt.in, func(t *testing.T) { - got := git.RefToFileName(tt.in) - if got != tt.want { - t.Fatalf("refToFileName(%q) = %q, want %q", tt.in, got, tt.want) - } - }) - } -} |
