container/initplace: check path equivalence by value
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m25s
Test / Hakurei (push) Successful in 3m6s
Test / Hpkg (push) Successful in 4m5s
Test / Sandbox (race detector) (push) Successful in 4m24s
Test / Hakurei (race detector) (push) Successful in 5m1s
Test / Flake checks (push) Successful in 1m19s
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m25s
Test / Hakurei (push) Successful in 3m6s
Test / Hpkg (push) Successful in 4m5s
Test / Sandbox (race detector) (push) Successful in 4m24s
Test / Hakurei (race detector) (push) Successful in 5m1s
Test / Flake checks (push) Successful in 1m19s
Fixes regression introduced while integrating Absolute. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
696e593898
commit
d65e5f817a
@ -4,7 +4,6 @@ import (
|
||||
"encoding/gob"
|
||||
"fmt"
|
||||
"os"
|
||||
"slices"
|
||||
. "syscall"
|
||||
)
|
||||
|
||||
@ -73,7 +72,8 @@ func (t *TmpfileOp) apply(state *setupState) error {
|
||||
|
||||
func (t *TmpfileOp) Is(op Op) bool {
|
||||
vt, ok := op.(*TmpfileOp)
|
||||
return ok && t.Path == vt.Path && slices.Equal(t.Data, vt.Data)
|
||||
return ok && t.Path != nil && vt.Path != nil && t.Path.Is(vt.Path) &&
|
||||
string(t.Data) == string(vt.Data)
|
||||
}
|
||||
func (*TmpfileOp) prefix() string { return "placing" }
|
||||
func (t *TmpfileOp) String() string {
|
||||
|
56
container/initplace_test.go
Normal file
56
container/initplace_test.go
Normal file
@ -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)`},
|
||||
})
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user