aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/initplace_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-20 19:19:27 +0900
committerOphestra <cat@gensokyo.uk>2025-08-20 19:19:27 +0900
commitd65e5f817aaf173ed5c61a0509de5089ae52e9e9 (patch)
treeb13db8395490028bc6e7f103e26444c3e1cd0b3c /container/initplace_test.go
parent696e5938989dc5652dbf56686c289dd6994c9d4c (diff)
container/initplace: check path equivalence by value
Fixes regression introduced while integrating Absolute. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/initplace_test.go')
-rw-r--r--container/initplace_test.go56
1 files changed, 56 insertions, 0 deletions
diff --git a/container/initplace_test.go b/container/initplace_test.go
new file mode 100644
index 00000000..e1d8163d
--- /dev/null
+++ b/container/initplace_test.go
@@ -0,0 +1,56 @@
+package container
+
+import "testing"
+
+func TestTmpfileOp(t *testing.T) {
+ checkOpsBuilder(t, []opsBuilderTestCase{
+ {"noref", new(Ops).Place(MustAbs("/etc/passwd"), []byte(`chronos:x:65534:65534:Hakurei:/var/empty:/bin/zsh`)), Ops{
+ &TmpfileOp{
+ Path: MustAbs("/etc/passwd"),
+ Data: []byte(`chronos:x:65534:65534:Hakurei:/var/empty:/bin/zsh`),
+ },
+ }},
+
+ {"ref", new(Ops).PlaceP(MustAbs("/etc/passwd"), new(*[]byte)), Ops{
+ &TmpfileOp{
+ Path: MustAbs("/etc/passwd"),
+ Data: []byte{},
+ },
+ }},
+ })
+
+ checkOpIs(t, []opIsTestCase{
+ {"zero", new(TmpfileOp), new(TmpfileOp), false},
+
+ {"differs path", &TmpfileOp{
+ Path: MustAbs("/etc/group"),
+ Data: []byte(`chronos:x:65534:65534:Hakurei:/var/empty:/bin/zsh`),
+ }, &TmpfileOp{
+ Path: MustAbs("/etc/passwd"),
+ Data: []byte(`chronos:x:65534:65534:Hakurei:/var/empty:/bin/zsh`),
+ }, false},
+
+ {"differs data", &TmpfileOp{
+ Path: MustAbs("/etc/passwd"),
+ Data: []byte(`chronos:x:65534:65534:Hakurei:/var/empty:/bin/zsh` + "\x00"),
+ }, &TmpfileOp{
+ Path: MustAbs("/etc/passwd"),
+ Data: []byte(`chronos:x:65534:65534:Hakurei:/var/empty:/bin/zsh`),
+ }, false},
+
+ {"equals", &TmpfileOp{
+ Path: MustAbs("/etc/passwd"),
+ Data: []byte(`chronos:x:65534:65534:Hakurei:/var/empty:/bin/zsh`),
+ }, &TmpfileOp{
+ Path: MustAbs("/etc/passwd"),
+ Data: []byte(`chronos:x:65534:65534:Hakurei:/var/empty:/bin/zsh`),
+ }, true},
+ })
+
+ checkOpMeta(t, []opMetaTestCase{
+ {"passwd", &TmpfileOp{
+ Path: MustAbs("/etc/passwd"),
+ Data: []byte(`chronos:x:65534:65534:Hakurei:/var/empty:/bin/zsh`),
+ }, "placing", `tmpfile "/etc/passwd" (49 bytes)`},
+ })
+}