forked from rosa/hakurei
internal/pkg: implementation revisions
This enables changing the behaviour of an artifact implementation without changing its IR structure. Unfortunately this changes the IR header structure resulting in many rebuilds. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"io"
|
||||
"io/fs"
|
||||
"math"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@@ -135,3 +136,36 @@ func TestIRRoundtrip(t *testing.T) {
|
||||
}
|
||||
checkWithCache(t, testCasesCache)
|
||||
}
|
||||
|
||||
func TestRevision(t *testing.T) {
|
||||
checkWithCache(t, []cacheTestCase{{"revision", 0, nil,
|
||||
func(t *testing.T, base *check.Absolute, c *pkg.Cache) {
|
||||
a := pkg.NewFile("", nil)
|
||||
var buf bytes.Buffer
|
||||
if err := c.EncodeAll(&buf, a); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := c.NewDecoder(
|
||||
bytes.NewReader(buf.Bytes()),
|
||||
).Decode(); err != nil {
|
||||
t.Fatalf("Decode: error = %v", err)
|
||||
}
|
||||
|
||||
p := buf.Bytes()
|
||||
p[8] = 0xfd
|
||||
wantErr := pkg.RevisionError{math.MaxUint64 - 2, math.MaxUint64}
|
||||
if _, err := c.NewDecoder(
|
||||
bytes.NewReader(p),
|
||||
).Decode(); !reflect.DeepEqual(err, wantErr) {
|
||||
t.Fatalf("Decode: error = %v, want %v", err, wantErr)
|
||||
}
|
||||
}, expectsFS{
|
||||
".": {Mode: fs.ModeDir | 0700},
|
||||
"checksum": {Mode: fs.ModeDir | 0700},
|
||||
"identifier": {Mode: fs.ModeDir | 0700},
|
||||
"substitute": {Mode: fs.ModeDir | 0700},
|
||||
"work": {Mode: fs.ModeDir | 0700},
|
||||
},
|
||||
}})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user