MCPcopy Create free account
hub / github.com/stretchr/testify / TestFileExists

Function TestFileExists

assert/assertions_test.go:2174–2206  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2172}
2173
2174func TestFileExists(t *testing.T) {
2175 mockT := new(testing.T)
2176 True(t, FileExists(mockT, "assertions.go"))
2177
2178 mockT = new(testing.T)
2179 False(t, FileExists(mockT, "random_file"))
2180
2181 mockT = new(testing.T)
2182 False(t, FileExists(mockT, "../_codegen"))
2183
2184 var tempFiles []string
2185
2186 link, err := getTempSymlinkPath("assertions.go")
2187 if err != nil {
2188 t.Fatal("could not create temp symlink, err:", err)
2189 }
2190 tempFiles = append(tempFiles, link)
2191 mockT = new(testing.T)
2192 True(t, FileExists(mockT, link))
2193
2194 link, err = getTempSymlinkPath("non_existent_file")
2195 if err != nil {
2196 t.Fatal("could not create temp symlink, err:", err)
2197 }
2198 tempFiles = append(tempFiles, link)
2199 mockT = new(testing.T)
2200 True(t, FileExists(mockT, link))
2201
2202 errs := cleanUpTempFiles(tempFiles)
2203 if len(errs) > 0 {
2204 t.Fatal("could not clean up temporary files")
2205 }
2206}
2207
2208func TestNoFileExists(t *testing.T) {
2209 mockT := new(testing.T)

Callers

nothing calls this directly

Calls 5

getTempSymlinkPathFunction · 0.85
cleanUpTempFilesFunction · 0.85
TrueFunction · 0.70
FileExistsFunction · 0.70
FalseFunction · 0.70

Tested by

no test coverage detected