| 107 | } |
| 108 | |
| 109 | func TestIsFile(t *testing.T) { |
| 110 | fs := afero.NewMemMapFs() |
| 111 | ctx := WithFS(context.Background(), fs) |
| 112 | |
| 113 | testFilePath := "/test-file.txt" |
| 114 | err := afero.WriteFile(fs, testFilePath, []byte("test"), 0o644) |
| 115 | assert.NoError(t, err) |
| 116 | |
| 117 | isFile, err := IsFile(ctx, testFilePath) |
| 118 | assert.True(t, isFile) |
| 119 | assert.Nil(t, err) |
| 120 | |
| 121 | isFile, err = IsFile(context.Background(), "/non-existent-file.txt") |
| 122 | assert.False(t, isFile) |
| 123 | assert.Nil(t, err) |
| 124 | } |
| 125 | |
| 126 | func TestHasJsonOrYamlExt(t *testing.T) { |
| 127 | tests := []struct { |