package legal import "testing" func TestStrictCopyleftBlocksProprietary(t *testing.T) { s := &Sentinel{Policy: StrictCopyleft()} _, err := s.Validate(LicenseInfo{ SpellName: "nvidia-driver", License: "PROPRIETARY", IsProprietary: true, }) if err == nil { t.Fatalf("strict_copyleft must block proprietary licenses") } } func TestCorporateLiteBlocksAGPL(t *testing.T) { s := &Sentinel{Policy: CorporateLite()} _, err := s.Validate(LicenseInfo{ SpellName: "mongodb", License: "AGPL-3.0", IsCopyleft: true, }) if err == nil { t.Fatalf("corporate_lite must block AGPL") } } func TestLawlessNeverBlocks(t *testing.T) { s := &Sentinel{Policy: Lawless()} _, err := s.Validate(LicenseInfo{ SpellName: "anything", License: "WTFPL", IsProprietary: true, }) if err != nil { t.Fatalf("lawless must never block, got: %v", err) } } func TestStrictAllowsGPL(t *testing.T) { s := &Sentinel{Policy: StrictCopyleft()} warnings, err := s.Validate(LicenseInfo{ SpellName: "wget", License: "GPL-3.0-or-later", IsCopyleft: true, }) if err != nil { t.Fatalf("strict_copyleft must allow GPL, got: %v", err) } if len(warnings) == 0 { t.Fatalf("expected a copyleft audit warning") } } func TestFamilyOf(t *testing.T) { cases := map[string]string{ "GPL-3.0-only": "GPL", "LGPL-2.1-or-later": "LGPL", "Apache-2.0": "APACHE", "MIT": "MIT", "AGPL-3.0": "AGPL", } for in, want := range cases { if got := familyOf(in); got != want { t.Errorf("familyOf(%q) = %q, want %q", in, got, want) } } }