diff --git a/internal/scaffold/changelog_json_test.go b/internal/scaffold/changelog_json_test.go new file mode 100644 index 0000000..94efb02 --- /dev/null +++ b/internal/scaffold/changelog_json_test.go @@ -0,0 +1,24 @@ +package scaffold + +import ( + "encoding/json" + "strings" + "testing" +) + +func TestChangelogJSONLowercase(t *testing.T) { + c := &Config{ID: "io.x.y", Namespace: "y", AppVersion: "0.1.0", Description: "d", + Listing: Listing{Changelog: []ChangelogRel{{Version: "0.1.0", Notes: []string{"first"}}}}} + b, _ := json.Marshal(BuildMetadata(c)) + s := string(b) + for _, k := range []string{`"version"`, `"notes"`} { + if !strings.Contains(s, k) { + t.Errorf("metadata changelog missing lowercase key %s", k) + } + } + for _, k := range []string{`"Version"`, `"Notes"`, `"Date"`} { + if strings.Contains(s, k) { + t.Errorf("metadata changelog has Go-cased key %s", k) + } + } +} diff --git a/internal/scaffold/config.go b/internal/scaffold/config.go index 7581cf8..07cc0c8 100644 --- a/internal/scaffold/config.go +++ b/internal/scaffold/config.go @@ -77,9 +77,9 @@ type Vendor struct { // ChangelogRel is one release's notes for the store page. type ChangelogRel struct { - Version string `yaml:"version"` - Date string `yaml:"date"` - Notes []string `yaml:"notes"` + Version string `json:"version" yaml:"version"` + Date string `json:"date,omitempty" yaml:"date"` + Notes []string `json:"notes,omitempty" yaml:"notes"` } // Publisher carries the path to the ed25519 signing key (generated once via