-func NewTestLogger() *zap.SugaredLogger {
- encoderCfg := zap.NewProductionEncoderConfig()
- encoderCfg.TimeKey = "timestamp"
- encoderCfg.EncodeTime = zapcore.ISO8601TimeEncoder
-
- core := zapcore.NewCore(
- zapcore.NewConsoleEncoder(encoderCfg),
- zapcore.Lock(os.Stdout),
- zap.DebugLevel,
- )
-
- cores := []zapcore.Core{core}
- l := zap.New(zapcore.NewTee(cores...))
- defer func() { _ = l.Sync() }()
- return l.Sugar()
+func NewTestLogger() *slog.Logger {
+ return slog.New(slog.NewTextHandler(os.Stdout, nil))
+}
+
+// assertTransferBytesEqual takes a string with a hexdump in the same format that `hexdump -C` produces and compares with
+// a hexdump for the bytes in got, after stripping the create/modify timestamps.
+// I don't love this, but as git does not preserve file create/modify timestamps, we either need to fully mock the
+// filesystem interactions or work around in this way.
+// TODO: figure out a better solution
+func assertTransferBytesEqual(t *testing.T, wantHexDump string, got []byte) bool {
+ if wantHexDump == "" {
+ return true
+ }
+
+ var clean []byte
+ clean = append(clean, got[:92]...) // keep the first 92 bytes
+ clean = append(clean, make([]byte, 16)...) // replace the next 16 bytes for create/modify timestamps
+ clean = append(clean, got[108:]...) // keep the rest
+
+ return assert.Equal(t, wantHexDump, hex.Dump(clean))