(t *testing.T, fs afero.Fs, pluginPath string, resourcePath string, mtime time.Time)
| 129 | } |
| 130 | |
| 131 | func addPluginFile(t *testing.T, fs afero.Fs, pluginPath string, resourcePath string, mtime time.Time) { |
| 132 | err := fs.MkdirAll(filepath.Join(cachePath, pluginPath), 0o755) |
| 133 | require.NoError(t, err, "can't create test folder for plugin file") |
| 134 | |
| 135 | err = fs.Chtimes(filepath.Join(cachePath, pluginPath), now, mtime) |
| 136 | require.NoError(t, err, "can't set times") |
| 137 | |
| 138 | err = afero.WriteFile(fs, filepath.Join(cachePath, pluginPath, resourcePath), []byte("foo"), 0o644) |
| 139 | require.NoError(t, err, "can't create test file") |
| 140 | |
| 141 | err = fs.Chtimes(filepath.Join(cachePath, pluginPath, resourcePath), now, mtime) |
| 142 | require.NoError(t, err, "can't set times") |
| 143 | |
| 144 | // as creating a file will update mtime of parent, we also want to |
| 145 | // set the mtime of parent to match that of the new child. |
| 146 | parent, _ := filepath.Split(filepath.Join(cachePath, pluginPath, resourcePath)) |
| 147 | parentInfo, err := fs.Stat(parent) |
| 148 | require.NoError(t, err, "can't stat parent") |
| 149 | if parentInfo.ModTime().After(mtime) { |
| 150 | require.NoError(t, fs.Chtimes(parent, now, mtime), "can't set mtime of parent to match child") |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | func addPluginFolder(t *testing.T, fs afero.Fs, pluginPath string, folderPath string, mtime time.Time) { |
| 155 | err := fs.MkdirAll(filepath.Join(cachePath, pluginPath, folderPath), 0o755) |
no test coverage detected