• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jlaffaye / ftp / 8113579643

01 Mar 2024 03:23PM UTC coverage: 72.431%. Remained the same
8113579643

Pull #365

github

web-flow
Bump github.com/stretchr/testify from 1.8.4 to 1.9.0

Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.4 to 1.9.0.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.4...v1.9.0)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #365: Bump github.com/stretchr/testify from 1.8.4 to 1.9.0

712 of 983 relevant lines covered (72.43%)

18.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.0
/walker.go
1
package ftp
2

3
import (
4
        "path"
5
)
6

7
// Walker traverses the directory tree of a remote FTP server
8
type Walker struct {
9
        serverConn *ServerConn
10
        root       string
11
        cur        *item
12
        stack      []*item
13
        descend    bool
14
}
15

16
type item struct {
17
        path  string
18
        entry *Entry
19
        err   error
20
}
21

22
// Next advances the Walker to the next file or directory,
23
// which will then be available through the Path, Stat, and Err methods.
24
// It returns false when the walk stops at the end of the tree.
25
func (w *Walker) Next() bool {
5✔
26
        // check if we need to init cur, maybe this should be inside Walk
5✔
27
        if w.cur == nil {
6✔
28
                w.cur = &item{
1✔
29
                        path: w.root,
1✔
30
                        entry: &Entry{
1✔
31
                                Type: EntryTypeFolder,
1✔
32
                        },
1✔
33
                }
1✔
34
        }
1✔
35

36
        if w.descend && w.cur.entry.Type == EntryTypeFolder {
6✔
37
                entries, err := w.serverConn.List(w.cur.path)
1✔
38

1✔
39
                // an error occurred, drop out and stop walking
1✔
40
                if err != nil {
1✔
41
                        w.cur.err = err
×
42
                        return false
×
43
                }
×
44

45
                for _, entry := range entries {
2✔
46
                        if entry.Name == "." || entry.Name == ".." {
1✔
47
                                continue
×
48
                        }
49

50
                        item := &item{
1✔
51
                                path:  path.Join(w.cur.path, entry.Name),
1✔
52
                                entry: entry,
1✔
53
                        }
1✔
54

1✔
55
                        w.stack = append(w.stack, item)
1✔
56
                }
57
        }
58

59
        if len(w.stack) == 0 {
6✔
60
                return false
1✔
61
        }
1✔
62

63
        // update cur
64
        i := len(w.stack) - 1
4✔
65
        w.cur = w.stack[i]
4✔
66
        w.stack = w.stack[:i]
4✔
67

4✔
68
        // reset SkipDir
4✔
69
        w.descend = true
4✔
70

4✔
71
        return true
4✔
72
}
73

74
// SkipDir tells the Next function to skip the currently processed directory
75
func (w *Walker) SkipDir() {
3✔
76
        w.descend = false
3✔
77
}
3✔
78

79
// Err returns the error, if any, for the most recent attempt by Next to
80
// visit a file or a directory. If a directory has an error, the walker
81
// will not descend in that directory
82
func (w *Walker) Err() error {
1✔
83
        return w.cur.err
1✔
84
}
1✔
85

86
// Stat returns info for the most recent file or directory
87
// visited by a call to Next.
88
func (w *Walker) Stat() *Entry {
1✔
89
        return w.cur.entry
1✔
90
}
1✔
91

92
// Path returns the path to the most recent file or directory
93
// visited by a call to Next. It contains the argument to Walk
94
// as a prefix; that is, if Walk is called with "dir", which is
95
// a directory containing the file "a", Path will return "dir/a".
96
func (w *Walker) Path() string {
2✔
97
        return w.cur.path
2✔
98
}
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc