Skip to content

Commit

Permalink
docs: add File funcs examples (#129)
Browse files Browse the repository at this point in the history
* docs: add File funcs examples

* docs: make examples easier to read
  • Loading branch information
alessio-perugini authored May 8, 2023
1 parent 94bcb7f commit 0b3064f
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
43 changes: 43 additions & 0 deletions examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package test
import (
"errors"
"fmt"
"io/fs"
"os"
"strings"
"time"
Expand Down Expand Up @@ -269,22 +270,64 @@ func ExampleFalse() {
}

// FileContains
func ExampleFileContains() {
_ = os.WriteFile("/tmp/example", []byte("foo bar baz"), fs.FileMode(0600))
FileContains(t, "/tmp/example", "bar")
// Output:
}

// FileContainsFS
func ExampleFileContainsFS() {
_ = os.WriteFile("/tmp/example", []byte("foo bar baz"), fs.FileMode(0600))
FileContainsFS(t, os.DirFS("/tmp"), "example", "bar")
// Output:
}

// FileExists
func ExampleFileExists() {
_ = os.WriteFile("/tmp/example", []byte{}, fs.FileMode(0600))
FileExists(t, "/tmp/example")
// Output:
}

// FileExistsFS
func ExampleFileExistsFS() {
_ = os.WriteFile("/tmp/example", []byte{}, fs.FileMode(0600))
FileExistsFS(t, os.DirFS("/tmp"), "example")
// Output:
}

// FileMode
func ExampleFileMode() {
_ = os.WriteFile("/tmp/example_fm", []byte{}, fs.FileMode(0600))
FileMode(t, "/tmp/example_fm", fs.FileMode(0600))
// Output:
}

// FileModeFS
func ExampleFileModeFS() {
_ = os.WriteFile("/tmp/example_fm", []byte{}, fs.FileMode(0600))
FileModeFS(t, os.DirFS("/tmp"), "example_fm", fs.FileMode(0600))
// Output:
}

// FileNotExists
func ExampleFileNotExists() {
FileNotExists(t, "/tmp/not_existing_file")
// Output:
}

// FileNotExistsFS
func ExampleFileNotExistsFS() {
FileNotExistsFS(t, os.DirFS("/tmp"), "not_existing_file")
// Output:
}

// FilePathValid
func ExampleFilePathValid() {
FilePathValid(t, "foo/bar/baz")
// Output:
}

// Greater

Expand Down
43 changes: 43 additions & 0 deletions must/examples_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0b3064f

Please sign in to comment.