1package utils
2
3import "testing"
4
5func TestValidateRepo(t *testing.T) {
6 t.Run("valid", func(t *testing.T) {
7 for _, repo := range []string{
8 "lower",
9 "Upper",
10 "with-dash",
11 "with/slash",
12 "withnumb3r5",
13 "with.dot",
14 "with_underline",
15 } {
16 t.Run(repo, func(t *testing.T) {
17 if err := ValidateRepo(repo); err != nil {
18 t.Errorf("expected no error, got %v", err)
19 }
20 })
21 }
22 })
23 t.Run("invalid", func(t *testing.T) {
24 for _, repo := range []string{
25 "with$",
26 "with@",
27 "with!",
28 } {
29 t.Run(repo, func(t *testing.T) {
30 if err := ValidateRepo(repo); err == nil {
31 t.Error("expected an error, got nil")
32 }
33 })
34 }
35 })
36}