aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/ir_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-07-23 16:21:20 +0900
committerOphestra <cat@gensokyo.uk>2026-07-23 16:39:34 +0900
commit67dbb68818026f3d7a64e9519cf1aac36468b7c9 (patch)
tree68f1e731242a9c8ef1912a195c2a6aefc53f6da5 /internal/pkg/ir_test.go
parent0e689d9983dee9f742c4ed4b2e716fbcb1b84e99 (diff)
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>
Diffstat (limited to 'internal/pkg/ir_test.go')
-rw-r--r--internal/pkg/ir_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/pkg/ir_test.go b/internal/pkg/ir_test.go
index ad6baa76..963cdc04 100644
--- a/internal/pkg/ir_test.go
+++ b/internal/pkg/ir_test.go
@@ -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},
+ },
+ }})
+}