// Licensed to Elasticsearch B.V. under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. Elasticsearch B.V. licenses this file to you 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. // +build !integration package file import ( "os" "path/filepath" "testing" "github.com/stretchr/testify/assert" ) func TestIsSameFile(t *testing.T) { absPath, err := filepath.Abs("../../tests/files/") assert.NotNil(t, absPath) assert.Nil(t, err) fileInfo1, err := os.Stat(absPath + "/logs/test.log") fileInfo2, err := os.Stat(absPath + "/logs/system.log") assert.Nil(t, err) assert.NotNil(t, fileInfo1) assert.NotNil(t, fileInfo2) file1 := &File{ FileInfo: fileInfo1, } file2 := &File{ FileInfo: fileInfo2, } file3 := &File{ FileInfo: fileInfo2, } assert.False(t, file1.IsSameFile(file2)) assert.False(t, file2.IsSameFile(file1)) assert.True(t, file1.IsSameFile(file1)) assert.True(t, file2.IsSameFile(file2)) assert.True(t, file3.IsSameFile(file2)) assert.True(t, file2.IsSameFile(file3)) }