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"
|
const tool = "go.maximumdirect.net/releasekit/cmd/releasekit"
|
||||||
|
|
||||||
var modules = []struct{ selector, dir, profile, product string }{
|
var modules = []struct{ selector, dir, profile string }{
|
||||||
{"core", ".", "releasekit.json", "CommandKit"},
|
{"core", ".", "releasekit.json"},
|
||||||
{"ckconfig", "integrations/ckconfig", "integrations/ckconfig/releasekit.json", "CommandKit ckconfig"},
|
{"ckconfig", "integrations/ckconfig", "integrations/ckconfig/releasekit.json"},
|
||||||
{"ckprompt", "integrations/ckprompt", "integrations/ckprompt/releasekit.json", "CommandKit ckprompt"},
|
{"ckprompt", "integrations/ckprompt", "integrations/ckprompt/releasekit.json"},
|
||||||
}
|
}
|
||||||
|
|
||||||
type fixture struct{ root, outside, log string }
|
type fixture struct{ root, outside, log string }
|
||||||
@@ -90,38 +90,28 @@ func lines(t *testing.T, path string) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestProfiles(t *testing.T) {
|
func TestProfiles(t *testing.T) {
|
||||||
f := newFixture(t)
|
|
||||||
for _, m := range modules {
|
for _, m := range modules {
|
||||||
t.Run(m.selector, func(t *testing.T) {
|
t.Run(m.selector, func(t *testing.T) {
|
||||||
var p struct {
|
var p struct {
|
||||||
Product string `json:"product"`
|
Module string `json:"module_dir"`
|
||||||
Module string `json:"module_dir"`
|
URL string `json:"expected_push_url"`
|
||||||
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"`
|
|
||||||
}
|
}
|
||||||
b, err := os.ReadFile(filepath.Join(f.root, m.profile))
|
b, err := os.ReadFile(filepath.Join("..", m.profile))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := json.Unmarshal(b, &p); err != nil {
|
if err := json.Unmarshal(b, &p); err != nil {
|
||||||
t.Fatal(err)
|
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" {
|
// The profile must agree with the launcher's module selection.
|
||||||
t.Fatalf("profile identity: %+v", p)
|
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"}) {
|
// The release procedure selects this exact publication endpoint.
|
||||||
t.Fatalf("validation: %+v", p.Validation)
|
// An empty or different value would weaken or misdirect that guard.
|
||||||
}
|
const pushURL = "ssh://git@forge.maximumdirect.net:22222/base-layer/commandkit.git"
|
||||||
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"}) {
|
if p.URL != pushURL {
|
||||||
t.Fatalf("delivery: %v", p.Delivery)
|
t.Errorf("expected_push_url = %q, want %q", p.URL, pushURL)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user