MCPcopy Index your code
hub / github.com/coder/coder / diffFileSystem

Function diffFileSystem

provisioner/terraform/cleanup_test.go:162–179  ·  view source on GitHub ↗
(t *testing.T, fs afero.Fs)

Source from the content-addressed store, hash-verified

160}
161
162func diffFileSystem(t *testing.T, fs afero.Fs) {
163 actual := dumpFileSystem(t, fs)
164
165 partialName := strings.Join(strings.Split(t.Name(), "/")[1:], "_")
166 goldenFile := filepath.Join("testdata", "cleanup-stale-plugins", partialName+".txt.golden")
167 if *updateGoldenFiles {
168 err := os.MkdirAll(filepath.Dir(goldenFile), 0o755)
169 require.NoError(t, err, "want no error creating golden file directory")
170
171 err = os.WriteFile(goldenFile, actual, 0o600)
172 require.NoError(t, err, "want no error creating golden file")
173 return
174 }
175
176 want, err := os.ReadFile(goldenFile)
177 require.NoError(t, err, "open golden file, run \"make gen/golden-files\" and commit the changes")
178 assert.Empty(t, cmp.Diff(want, actual), "golden file mismatch (-want +got): %s, run \"make gen/golden-files\", verify and commit the changes", goldenFile)
179}
180
181func dumpFileSystem(t *testing.T, fs afero.Fs) []byte {
182 var buffer bytes.Buffer

Callers 1

TestPluginCache_GoldenFunction · 0.85

Calls 6

dumpFileSystemFunction · 0.85
MkdirAllMethod · 0.80
NameMethod · 0.65
WriteFileMethod · 0.65
ReadFileMethod · 0.65
EmptyMethod · 0.45

Tested by

no test coverage detected