(t *testing.T)
| 27 | ) |
| 28 | |
| 29 | func TestRequestSimple(t *testing.T) { |
| 30 | // Verify that the model performs a request and creates a file based on |
| 31 | // an incoming index update. |
| 32 | |
| 33 | m, fc, fcfg := setupModelWithConnection(t) |
| 34 | tfs := fcfg.Filesystem() |
| 35 | defer cleanupModelAndRemoveDir(m, tfs.URI()) |
| 36 | |
| 37 | // We listen for incoming index updates and trigger when we see one for |
| 38 | // the expected test file. |
| 39 | done := make(chan struct{}) |
| 40 | fc.setIndexFn(func(_ context.Context, folder string, fs []protocol.FileInfo) error { |
| 41 | select { |
| 42 | case <-done: |
| 43 | t.Error("More than one index update sent") |
| 44 | default: |
| 45 | } |
| 46 | for _, f := range fs { |
| 47 | if f.Name == "testfile" { |
| 48 | close(done) |
| 49 | return nil |
| 50 | } |
| 51 | } |
| 52 | return nil |
| 53 | }) |
| 54 | |
| 55 | // Send an update for the test file, wait for it to sync and be reported back. |
| 56 | contents := []byte("test file contents\n") |
| 57 | fc.addFile("testfile", 0o644, protocol.FileInfoTypeFile, contents) |
| 58 | fc.addFile("testfile", 0o644, protocol.FileInfoTypeFile, contents) |
| 59 | fc.sendIndexUpdate() |
| 60 | select { |
| 61 | case <-done: |
| 62 | case <-time.After(10 * time.Second): |
| 63 | t.Fatal("timed out") |
| 64 | } |
| 65 | |
| 66 | // Verify the contents |
| 67 | if err := equalContents(tfs, "testfile", contents); err != nil { |
| 68 | t.Error("File did not sync correctly:", err) |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | func TestSymlinkTraversalRead(t *testing.T) { |
| 73 | // Verify that a symlink can not be traversed for reading. |
nothing calls this directly
no test coverage detected