Trim release profile tests to module and publication safeguards
This commit is contained in:
@@ -13,10 +13,10 @@ import (
|
||||
|
||||
const tool = "go.maximumdirect.net/releasekit/cmd/releasekit"
|
||||
|
||||
var modules = []struct{ selector, dir, profile, product string }{
|
||||
{"core", ".", "releasekit.json", "CommandKit"},
|
||||
{"ckconfig", "integrations/ckconfig", "integrations/ckconfig/releasekit.json", "CommandKit ckconfig"},
|
||||
{"ckprompt", "integrations/ckprompt", "integrations/ckprompt/releasekit.json", "CommandKit ckprompt"},
|
||||
var modules = []struct{ selector, dir, profile string }{
|
||||
{"core", ".", "releasekit.json"},
|
||||
{"ckconfig", "integrations/ckconfig", "integrations/ckconfig/releasekit.json"},
|
||||
{"ckprompt", "integrations/ckprompt", "integrations/ckprompt/releasekit.json"},
|
||||
}
|
||||
|
||||
type fixture struct{ root, outside, log string }
|
||||
@@ -90,38 +90,28 @@ func lines(t *testing.T, path string) []string {
|
||||
}
|
||||
|
||||
func TestProfiles(t *testing.T) {
|
||||
f := newFixture(t)
|
||||
for _, m := range modules {
|
||||
t.Run(m.selector, func(t *testing.T) {
|
||||
var p struct {
|
||||
Product string `json:"product"`
|
||||
Module string `json:"module_dir"`
|
||||
Remote string `json:"remote"`
|
||||
URL string `json:"expected_push_url"`
|
||||
Validation struct {
|
||||
Shared []string `json:"shared_files"`
|
||||
Format bool `json:"go_format"`
|
||||
Markdown map[string]any `json:"markdown"`
|
||||
Distribution map[string]bool `json:"module_distribution"`
|
||||
Forbidden []string `json:"forbidden_files"`
|
||||
} `json:"validation"`
|
||||
Delivery map[string]string `json:"delivery"`
|
||||
Module string `json:"module_dir"`
|
||||
URL string `json:"expected_push_url"`
|
||||
}
|
||||
b, err := os.ReadFile(filepath.Join(f.root, m.profile))
|
||||
b, err := os.ReadFile(filepath.Join("..", m.profile))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := json.Unmarshal(b, &p); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if p.Product != m.product || p.Module != m.dir || p.Remote != "origin" || p.URL != "ssh://git@forge.maximumdirect.net:22222/base-layer/commandkit.git" {
|
||||
t.Fatalf("profile identity: %+v", p)
|
||||
// The profile must agree with the launcher's module selection.
|
||||
if p.Module != m.dir {
|
||||
t.Errorf("module_dir = %q, want %q", p.Module, m.dir)
|
||||
}
|
||||
if !reflect.DeepEqual(p.Validation.Shared, []string{"COPYRIGHT", "LICENSE", "docs/oss/attribution.md"}) || !p.Validation.Format || p.Validation.Markdown == nil || len(p.Validation.Markdown) != 0 || !reflect.DeepEqual(p.Validation.Distribution, map[string]bool{"workspace_files": true, "local_replacements": true}) || !reflect.DeepEqual(p.Validation.Forbidden, []string{".releasekit/gitea-token"}) {
|
||||
t.Fatalf("validation: %+v", p.Validation)
|
||||
}
|
||||
if !reflect.DeepEqual(p.Delivery, map[string]string{"forge": "gitea", "base_url": "https://forge.maximumdirect.net", "owner": "base-layer", "repository": "commandkit", "token_file": ".releasekit/gitea-token"}) {
|
||||
t.Fatalf("delivery: %v", p.Delivery)
|
||||
// The release procedure selects this exact publication endpoint.
|
||||
// An empty or different value would weaken or misdirect that guard.
|
||||
const pushURL = "ssh://git@forge.maximumdirect.net:22222/base-layer/commandkit.git"
|
||||
if p.URL != pushURL {
|
||||
t.Errorf("expected_push_url = %q, want %q", p.URL, pushURL)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user