check / check (push) Failing after 4s
MFFilePath gains mode (field 304): a file's permission bits, 0777 at most, or 0000, meaning none recorded. gen and freshen record real modes only with --include-permissions (ScannerOptions.IncludePermissions); the builder keeps only mode.Perm(), so setuid, setgid and sticky are never written. list -l and export show the mode in octal. check reports MODE_MISMATCH for a recorded mode other than 0000 the file lacks. fetch refuses a manifest with a mode above 0777 before requesting any file, sets only the permission bits of each recorded mode on the files it writes, and downloads again a present file whose mode differs. The decoding-cost bound counts a file entry at 176 bytes, up from 160. Model: opus-5-5
56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
package mfer_test
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"google.golang.org/protobuf/reflect/protoreflect"
|
|
"sneak.berlin/go/mfer/mfer"
|
|
)
|
|
|
|
// mf.pb.go is generated from mf.proto and committed. `make generate`
|
|
// records the hash of the mf.proto it generated from in mf.proto.sha256.
|
|
func TestGeneratedCodeMatchesProto(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
proto, err := os.ReadFile("mf.proto")
|
|
require.NoError(t, err)
|
|
|
|
recorded, err := os.ReadFile("mf.proto.sha256")
|
|
require.NoError(t, err)
|
|
|
|
recordedHash, _, _ := strings.Cut(string(recorded), " ")
|
|
sum := sha256.Sum256(proto)
|
|
require.Equal(t, recordedHash, hex.EncodeToString(sum[:]),
|
|
"mfer/mf.proto has changed since mfer/mf.pb.go was generated "+
|
|
"from it: run `make generate` and commit the result")
|
|
}
|
|
|
|
// A file entry has exactly the fields docs/FORMAT.md lists for MFFilePath.
|
|
func TestFileEntryFieldsMatchSpec(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
want := map[string]protoreflect.FieldNumber{
|
|
"path": 1,
|
|
"size": 2,
|
|
"hashes": 3,
|
|
"mimeType": 301,
|
|
"mtime": 302,
|
|
"ctime": 303,
|
|
"mode": 304,
|
|
}
|
|
|
|
got := map[string]protoreflect.FieldNumber{}
|
|
|
|
fields := (&mfer.MFFilePath{}).ProtoReflect().Descriptor().Fields()
|
|
for i := range fields.Len() {
|
|
got[string(fields.Get(i).Name())] = fields.Get(i).Number()
|
|
}
|
|
|
|
require.Equal(t, want, got)
|
|
}
|