mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans, usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0. Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
package ossfunding
|
|
|
|
import "testing"
|
|
|
|
func TestFromPURL(t *testing.T) {
|
|
cases := []struct {
|
|
purl string
|
|
wantKind Kind
|
|
wantHandle string
|
|
}{
|
|
{"pkg:golang/github.com/gin-gonic/[email protected]", KindGitHubSponsors, "gin-gonic"},
|
|
{"pkg:golang/github.com/google/[email protected]", KindGitHubSponsors, "google"},
|
|
{"pkg:golang/golang.org/x/[email protected]", KindGitHubSponsors, "golang"},
|
|
{"pkg:golang/gitlab.com/acme/widget@v2", KindGitHubSponsors, "acme"},
|
|
{"pkg:npm/[email protected]", KindUnresolved, ""},
|
|
{"pkg:pypi/[email protected]", KindUnresolved, ""},
|
|
{"", KindUnresolved, ""},
|
|
}
|
|
for _, tc := range cases {
|
|
t.Run(tc.purl, func(t *testing.T) {
|
|
got := FromPURL(tc.purl)
|
|
if got.Kind != tc.wantKind {
|
|
t.Fatalf("kind = %q, want %q", got.Kind, tc.wantKind)
|
|
}
|
|
if got.Handle != tc.wantHandle {
|
|
t.Fatalf("handle = %q, want %q", got.Handle, tc.wantHandle)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestTargetString(t *testing.T) {
|
|
if got := (Target{Kind: KindGitHubSponsors, Handle: "gin-gonic"}).String(); got != "github_sponsors:gin-gonic" {
|
|
t.Fatalf("String() = %q", got)
|
|
}
|
|
if got := Unresolved().String(); got != "unresolved" {
|
|
t.Fatalf("Unresolved String() = %q", got)
|
|
}
|
|
}
|
|
|
|
func TestPURLResolver(t *testing.T) {
|
|
r := PURLResolver{}
|
|
if got := r.Resolve("pkg:golang/github.com/gin-gonic/gin@v1"); got.Handle != "gin-gonic" {
|
|
t.Fatalf("resolver handle = %q", got.Handle)
|
|
}
|
|
}
|