-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
31 lines (28 loc) · 720 Bytes
/
main_test.go
File metadata and controls
31 lines (28 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import (
"testing"
)
func TestIsValidRepo(t *testing.T) {
tests := []struct {
name string
repo string
expected bool
}{
{"valid repo", "owner/repo", true},
{"valid repo with dash", "owner-name/repo-name", true},
{"valid repo with numbers", "owner123/repo456", true},
{"missing owner", "/repo", false},
{"missing repo", "owner/", false},
{"no slash", "ownerrepo", false},
{"too many slashes", "owner/repo/extra", false},
{"empty string", "", false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := isValidRepo(tt.repo)
if result != tt.expected {
t.Errorf("isValidRepo(%q) = %v, want %v", tt.repo, result, tt.expected)
}
})
}
}