Home / Function/ Test_isFile() — fiber Function Reference

Test_isFile() — fiber Function Reference

Architecture documentation for the Test_isFile() function in static_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  aff78297_f5ef_a5fc_ddf3_473901fda057["Test_isFile()"]
  f26a2d79_1e01_f027_82eb_45c4308747e8["static_test.go"]
  aff78297_f5ef_a5fc_ddf3_473901fda057 -->|defined in| f26a2d79_1e01_f027_82eb_45c4308747e8
  style aff78297_f5ef_a5fc_ddf3_473901fda057 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/static/static_test.go lines 700–773

func Test_isFile(t *testing.T) {
	t.Parallel()

	cases := []struct {
		filesystem fs.FS
		gotError   error
		name       string
		path       string
		expected   bool
	}{
		{
			name:       "file",
			path:       "index.html",
			filesystem: os.DirFS("../../.github"),
			expected:   true,
		},
		{
			name:       "file",
			path:       "index2.html",
			filesystem: os.DirFS("../../.github"),
			expected:   false,
			gotError:   fs.ErrNotExist,
		},
		{
			name:       "directory",
			path:       ".",
			filesystem: os.DirFS("../../.github"),
			expected:   false,
		},
		{
			name:       "directory",
			path:       "not_exists",
			filesystem: os.DirFS("../../.github"),
			expected:   false,
			gotError:   fs.ErrNotExist,
		},
		{
			name:       "directory",
			path:       ".",
			filesystem: os.DirFS(testCSSDir),
			expected:   false,
		},
		{
			name:       "file",
			path:       testCSSDir + "/style.css",
			filesystem: nil,
			expected:   true,
		},
		{
			name:       "file",
			path:       testCSSDir + "/style2.css",
			filesystem: nil,
			expected:   false,
			gotError:   fs.ErrNotExist,
		},
		{
			name:       "directory",
			path:       testCSSDir,
			filesystem: nil,
			expected:   false,
		},
	}

	for _, c := range cases {
		t.Run(c.name, func(t *testing.T) {
			c := c
			t.Parallel()

			actual, err := isFile(c.path, c.filesystem)
			require.ErrorIs(t, err, c.gotError)
			require.Equal(t, c.expected, actual)
		})
	}
}

Domain

Subdomains

Frequently Asked Questions

What does Test_isFile() do?
Test_isFile() is a function in the fiber codebase, defined in middleware/static/static_test.go.
Where is Test_isFile() defined?
Test_isFile() is defined in middleware/static/static_test.go at line 700.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free