MCPcopy Create free account
hub / github.com/coder/coder / addPluginFile

Function addPluginFile

provisioner/terraform/cleanup_test.go:131–152  ·  view source on GitHub ↗
(t *testing.T, fs afero.Fs, pluginPath string, resourcePath string, mtime time.Time)

Source from the content-addressed store, hash-verified

129}
130
131func 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
154func addPluginFolder(t *testing.T, fs afero.Fs, pluginPath string, folderPath string, mtime time.Time) {
155 err := fs.MkdirAll(filepath.Join(cachePath, pluginPath, folderPath), 0o755)

Callers 1

TestPluginCache_GoldenFunction · 0.85

Calls 2

MkdirAllMethod · 0.80
WriteFileMethod · 0.65

Tested by

no test coverage detected