cubefs/util/fileutil/write_test.go
gukaifeng 2e24163a51 fix(metanode): fsync the crc file after wirte
Signed-off-by: gukaifeng <gukaifeng@xiaomi.com>
Signed-off-by: slasher <shenjie1@oppo.com>
2025-01-08 18:01:42 +08:00

32 lines
1.0 KiB
Go

// Copyright 2024 The CubeFS Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
package fileutil_test
import (
"os"
"path/filepath"
"testing"
"github.com/cubefs/cubefs/util/fileutil"
"github.com/stretchr/testify/require"
)
func TestWriteFileWithSync(t *testing.T) {
require.Error(t, fileutil.WriteFileWithSync(os.TempDir(), nil, 0o644))
filename := filepath.Join(os.TempDir(), "TestWriteFileWithSync.file")
defer os.RemoveAll(filename)
require.NoError(t, fileutil.WriteFileWithSync(filename, make([]byte, 32), 0o644))
}