package gnopm import ( "strings" "testing" "gno.land/p/nt/uassert/v0" ) func TestValidCommit(t *testing.T) { sha1 := strings.Repeat("a", 40) sha256 := strings.Repeat("0", 64) cases := []struct { name string in string want bool }{ {"sha1", sha1, true}, {"sha256", sha256, true}, {"mixed hex", "0123456789abcdef0123456789abcdef01234567", true}, {"empty", "", false}, {"too short", strings.Repeat("a", 39), false}, {"between the two lengths", strings.Repeat("a", 41), false}, {"uppercase", strings.Repeat("A", 40), false}, {"non hex", strings.Repeat("g", 40), false}, {"abbreviated", "0123456", false}, } for _, tc := range cases { uassert.Equal(t, tc.want, ValidCommit(tc.in), tc.name) } } func TestValidRepo(t *testing.T) { cases := []struct { name string in string want bool }{ {"github", "https://github.com/gnolang/gno", true}, {"no path", "https://example.com", true}, {"trailing slash", "https://example.com/x/", true}, {"port is not a host character here", "https://example.com:8443/x", false}, {"empty", "", false}, {"http", "http://github.com/gnolang/gno", false}, {"git scheme", "git://github.com/gnolang/gno", false}, {"ssh scheme", "ssh://git@github.com/gnolang/gno", false}, {"javascript", "javascript:alert(1)", false}, {"data url", "data:text/html,