Something went wrong. Try again.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344package cli
import "testing"
func TestParseRepoRef(t *testing.T) { for _, tt := range []struct { in string want repoRef }{ {"alice.example.com/proj", repoRef{Owner: "alice.example.com", Name: "proj"}}, {"@alice.example.com/proj", repoRef{Owner: "alice.example.com", Name: "proj"}}, {"tangled.org/alice.example.com/proj", repoRef{Owner: "alice.example.com", Name: "proj"}}, {"did:plc:repo", repoRef{DID: "did:plc:repo"}}, {"proj", repoRef{Name: "proj"}}, // a web URL's path may continue past the repository name {"https://tangled.org/alice.example.com/proj/issues/3", repoRef{Owner: "alice.example.com", Name: "proj"}}, {"https://knot.example.com/did:plc:repo", repoRef{DID: "did:plc:repo"}}, {"https://knot.example.com/did:plc:alice/proj.git", repoRef{Owner: "did:plc:alice", Name: "proj"}}, {"git@knot.example.com:alice.example.com/proj.git", repoRef{Owner: "alice.example.com", Name: "proj"}}, {"git@knot.example.com:did:plc:repo", repoRef{DID: "did:plc:repo"}}, {"knot.example.com:did:plc:alice/proj", repoRef{Owner: "did:plc:alice", Name: "proj"}}, {"ssh://git@knot.example.com:2222/did:plc:repo", repoRef{DID: "did:plc:repo"}}, } { got, err := parseRepoRef(tt.in) if err != nil || got != tt.want { t.Errorf("parseRepoRef(%q) = %+v, %v; want %+v", tt.in, got, err, tt.want) } }}
func TestParseTicketArg(t *testing.T) { for _, tt := range []struct{ in, number, repo string }{ {"12", "12", ""}, {"#12", "12", ""}, {"https://tangled.org/alice.example.com/proj/pulls/3/1", "3", "https://tangled.org/alice.example.com/proj"}, {"https://tangled.org/alice.example.com/proj/issues/3lzq4w5qk2c2a#comment", "3lzq4w5qk2c2a", "https://tangled.org/alice.example.com/proj"}, } { number, repo := parseTicketArg(tt.in) if number != tt.number || repo != tt.repo { t.Errorf("parseTicketArg(%q) = %q, %q; want %q, %q", tt.in, number, repo, tt.number, tt.repo) } }}