Record the inputs of a build's source fingerprint in its build record (issue 1215)
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package link
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/delivery"
|
||||
)
|
||||
|
||||
// 1215/AC4: the builder's result on the wire carries the inputs, under source-inputs, and reads back unchanged.
|
||||
func TestABuildResultCarriesTheSourceInputs(t *testing.T) {
|
||||
in := &delivery.SourceInputs{Module: "m", Tree: "t", Bases: []string{"x@sha256:a"},
|
||||
Contexts: map[string]string{"c": "narrow:1"}, Toolchains: map[string]string{"c": "go sha256:b 01"}, Unpinned: "why"}
|
||||
raw, err := json.Marshal(BuildResult{ID: "build-1", SourceInputs: in})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var wire map[string]json.RawMessage
|
||||
if err := json.Unmarshal(raw, &wire); err != nil || wire["source-inputs"] == nil {
|
||||
t.Fatalf("the result on the wire has no source-inputs: %s", raw)
|
||||
}
|
||||
var back BuildResult
|
||||
if err := json.Unmarshal(raw, &back); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(back.SourceInputs, in) {
|
||||
t.Errorf("read back as %+v, not %+v", back.SourceInputs, in)
|
||||
}
|
||||
raw, _ = json.Marshal(BuildResult{ID: "build-2"})
|
||||
wire = nil
|
||||
if err := json.Unmarshal(raw, &wire); err != nil || wire["source-inputs"] != nil {
|
||||
t.Errorf("a result with none writes source-inputs: %s", raw)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user