diff --git a/internal/store/json.go b/internal/store/json.go index 096d73334..9815b0170 100644 --- a/internal/store/json.go +++ b/internal/store/json.go @@ -71,11 +71,11 @@ type sourceV0 struct { type sourcesV0 map[string]sourceV0 type changeV0 struct { - Commit string `json:"commit"` - Message string `json:"message"` - Revision *int `json:"revision"` - Timestamp string `json:"timestamp"` - // BUG: We are currently not (un)marshalling the Blueprint field. + Commit string `json:"commit"` + Message string `json:"message"` + Revision *int `json:"revision"` + Timestamp string `json:"timestamp"` + Blueprint blueprint.Blueprint `json:"blueprint"` } type changesV0 map[string]map[string]changeV0 @@ -203,6 +203,7 @@ func newChangesFromV0(changesStruct changesV0) map[string]map[string]blueprint.C Message: change.Message, Revision: change.Revision, Timestamp: change.Timestamp, + Blueprint: change.Blueprint, } } changes[name] = commits @@ -332,6 +333,7 @@ func newChangesV0(changes map[string]map[string]blueprint.Change) changesV0 { Message: change.Message, Revision: change.Revision, Timestamp: change.Timestamp, + Blueprint: change.Blueprint, } } changesStruct[name] = commitsStruct diff --git a/internal/store/json_test.go b/internal/store/json_test.go index 89846a101..03b64e876 100644 --- a/internal/store/json_test.go +++ b/internal/store/json_test.go @@ -699,6 +699,69 @@ func Test_newChangesFromV0(t *testing.T) { }, }, }, + }, + { + name: "Blueprint Changes With Blueprint", + changes: changesV0{ + "test-blueprint-changes-1": { + "4774980638f4162d9909a613c3ccd938e60bb3a9": { + Commit: "4774980638f4162d9909a613c3ccd938e60bb3a9", + Message: "Recipe test-blueprint-changes-1, version 0.1.2 saved.", + Revision: nil, + Timestamp: "2020-07-29T09:52:07Z", + Blueprint: blueprint.Blueprint{ + Name: "test-blueprint-changes-1", + Version: "0.1.2", + }, + }, + "72fdb76b9994bd72770e283bf3a5206756daf497": { + Commit: "72fdb76b9994bd72770e283bf3a5206756daf497", + Message: "Recipe test-blueprint-changes-1, version 0.1.1 saved.", + Revision: nil, + Timestamp: "2020-07-09T13:33:06Z", + Blueprint: blueprint.Blueprint{ + Name: "test-blueprint-changes-1", + Version: "0.1.1", + }, + }, + "79e2043a83637ffdd4db078c6da23deaae09c84b": { + Commit: "79e2043a83637ffdd4db078c6da23deaae09c84b", + Message: "Recipe test-blueprint-changes-1, version 0.0.1 saved.", + Revision: nil, + Timestamp: "2020-07-07T02:57:00Z", + }, + }, + }, + want: map[string]map[string]blueprint.Change{ + "test-blueprint-changes-1": { + "4774980638f4162d9909a613c3ccd938e60bb3a9": { + Commit: "4774980638f4162d9909a613c3ccd938e60bb3a9", + Message: "Recipe test-blueprint-changes-1, version 0.1.2 saved.", + Revision: nil, + Timestamp: "2020-07-29T09:52:07Z", + Blueprint: blueprint.Blueprint{ + Name: "test-blueprint-changes-1", + Version: "0.1.2", + }, + }, + "72fdb76b9994bd72770e283bf3a5206756daf497": { + Commit: "72fdb76b9994bd72770e283bf3a5206756daf497", + Message: "Recipe test-blueprint-changes-1, version 0.1.1 saved.", + Revision: nil, + Timestamp: "2020-07-09T13:33:06Z", + Blueprint: blueprint.Blueprint{ + Name: "test-blueprint-changes-1", + Version: "0.1.1", + }, + }, + "79e2043a83637ffdd4db078c6da23deaae09c84b": { + Commit: "79e2043a83637ffdd4db078c6da23deaae09c84b", + Message: "Recipe test-blueprint-changes-1, version 0.0.1 saved.", + Revision: nil, + Timestamp: "2020-07-07T02:57:00Z", + }, + }, + }, }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -818,6 +881,69 @@ func Test_newChangesV0(t *testing.T) { }, }, }, + { + name: "Blueprint Changes With Blueprint", + changes: map[string]map[string]blueprint.Change{ + "test-blueprint-changes-1": { + "4774980638f4162d9909a613c3ccd938e60bb3a9": { + Commit: "4774980638f4162d9909a613c3ccd938e60bb3a9", + Message: "Recipe test-blueprint-changes-1, version 0.1.2 saved.", + Revision: nil, + Timestamp: "2020-07-29T09:52:07Z", + Blueprint: blueprint.Blueprint{ + Name: "test-blueprint-changes-1", + Version: "0.1.2", + }, + }, + "72fdb76b9994bd72770e283bf3a5206756daf497": { + Commit: "72fdb76b9994bd72770e283bf3a5206756daf497", + Message: "Recipe test-blueprint-changes-1, version 0.1.1 saved.", + Revision: nil, + Timestamp: "2020-07-09T13:33:06Z", + Blueprint: blueprint.Blueprint{ + Name: "test-blueprint-changes-1", + Version: "0.1.1", + }, + }, + "79e2043a83637ffdd4db078c6da23deaae09c84b": { + Commit: "79e2043a83637ffdd4db078c6da23deaae09c84b", + Message: "Recipe test-blueprint-changes-1, version 0.0.1 saved.", + Revision: nil, + Timestamp: "2020-07-07T02:57:00Z", + }, + }, + }, + want: changesV0{ + "test-blueprint-changes-1": { + "4774980638f4162d9909a613c3ccd938e60bb3a9": { + Commit: "4774980638f4162d9909a613c3ccd938e60bb3a9", + Message: "Recipe test-blueprint-changes-1, version 0.1.2 saved.", + Revision: nil, + Timestamp: "2020-07-29T09:52:07Z", + Blueprint: blueprint.Blueprint{ + Name: "test-blueprint-changes-1", + Version: "0.1.2", + }, + }, + "72fdb76b9994bd72770e283bf3a5206756daf497": { + Commit: "72fdb76b9994bd72770e283bf3a5206756daf497", + Message: "Recipe test-blueprint-changes-1, version 0.1.1 saved.", + Revision: nil, + Timestamp: "2020-07-09T13:33:06Z", + Blueprint: blueprint.Blueprint{ + Name: "test-blueprint-changes-1", + Version: "0.1.1", + }, + }, + "79e2043a83637ffdd4db078c6da23deaae09c84b": { + Commit: "79e2043a83637ffdd4db078c6da23deaae09c84b", + Message: "Recipe test-blueprint-changes-1, version 0.0.1 saved.", + Revision: nil, + Timestamp: "2020-07-07T02:57:00Z", + }, + }, + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {