github.com/mgoltzsche/ctnr@v0.7.1-alpha/pkg/fs/source/sourcelink_test.go (about)

     1  package source
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/mgoltzsche/ctnr/pkg/fs"
     7  	"github.com/mgoltzsche/ctnr/pkg/fs/testutils"
     8  	"github.com/stretchr/testify/assert"
     9  	"github.com/stretchr/testify/require"
    10  )
    11  
    12  func assertSourceWriteWithHardlinkSupport(t *testing.T, testee fs.Source, expectedDefaultLine string) {
    13  	for _, c := range []struct {
    14  		written  map[fs.Source]string
    15  		expected string
    16  	}{
    17  		{map[fs.Source]string{}, expectedDefaultLine},
    18  		{map[fs.Source]string{testee: "/existing-file"}, "/file hlink=/existing-file"},
    19  	} {
    20  		writerMock := testutils.NewWriterMock(t, fs.AttrsAll)
    21  		err := testee.Write("/file", "", writerMock, c.written)
    22  		require.NoError(t, err)
    23  		if !assert.Equal(t, []string{c.expected}, writerMock.Written, "hardlink support") {
    24  			t.FailNow()
    25  		}
    26  	}
    27  }