newRunIndividual initialise the remote and local for testing and returns a run object. Pass in true to make individual tests or false to use the global one. r.Flocal is an empty local Fs r.Fremote is an empty remote Fs Finalise() will tidy them away when done.
(t *testing.T, individual bool)
| 142 | // |
| 143 | // Finalise() will tidy them away when done. |
| 144 | func newRunIndividual(t *testing.T, individual bool) *Run { |
| 145 | ctx := context.Background() |
| 146 | var r *Run |
| 147 | if individual { |
| 148 | r = newRun() |
| 149 | } else { |
| 150 | // If not individual, use the global one with the clean method overridden |
| 151 | r = new(Run) |
| 152 | *r = *oneRun |
| 153 | r.cleanRemote = func() { |
| 154 | var toDelete []string |
| 155 | err := walk.ListR(ctx, r.Fremote, "", true, -1, walk.ListAll, func(entries fs.DirEntries) error { |
| 156 | for _, entry := range entries { |
| 157 | switch x := entry.(type) { |
| 158 | case fs.Object: |
| 159 | retry(t, fmt.Sprintf("removing file %q", x.Remote()), func() error { return x.Remove(ctx) }) |
| 160 | case fs.Directory: |
| 161 | toDelete = append(toDelete, x.Remote()) |
| 162 | } |
| 163 | } |
| 164 | return nil |
| 165 | }) |
| 166 | if err == fs.ErrorDirNotFound { |
| 167 | return |
| 168 | } |
| 169 | require.NoError(t, err) |
| 170 | sort.Strings(toDelete) |
| 171 | for i := len(toDelete) - 1; i >= 0; i-- { |
| 172 | dir := toDelete[i] |
| 173 | retry(t, fmt.Sprintf("removing dir %q", dir), func() error { |
| 174 | return r.Fremote.Rmdir(ctx, dir) |
| 175 | }) |
| 176 | } |
| 177 | // Check remote is empty |
| 178 | CheckListingWithPrecision(t, r.Fremote, []Item{}, []string{}, r.Fremote.Precision()) |
| 179 | // Clear the remote cache |
| 180 | cache.Clear() |
| 181 | } |
| 182 | } |
| 183 | r.Logf = t.Logf |
| 184 | r.Fatalf = t.Fatalf |
| 185 | r.Logf("Remote %q, Local %q, Modify Window %q", r.Fremote, r.Flocal, fs.GetModifyWindow(ctx, r.Fremote)) |
| 186 | t.Cleanup(r.Finalise) |
| 187 | return r |
| 188 | } |
| 189 | |
| 190 | // NewRun initialise the remote and local for testing and returns a |
| 191 | // run object. Call this from the tests. |
no test coverage detected
searching dependent graphs…