(t *testing.T)
| 55 | } |
| 56 | |
| 57 | func TestCompactLowerdirOption(t *testing.T) { |
| 58 | tcases := []struct { |
| 59 | opts []string |
| 60 | commondir string |
| 61 | newopts []string |
| 62 | }{ |
| 63 | // no lowerdir or only one |
| 64 | { |
| 65 | []string{"workdir=a"}, |
| 66 | "", |
| 67 | []string{"workdir=a"}, |
| 68 | }, |
| 69 | { |
| 70 | []string{"workdir=a", "lowerdir=b"}, |
| 71 | "", |
| 72 | []string{"workdir=a", "lowerdir=b"}, |
| 73 | }, |
| 74 | |
| 75 | // >= 2 lowerdir |
| 76 | { |
| 77 | []string{"lowerdir=/snapshots/1/fs:/snapshots/10/fs"}, |
| 78 | "/snapshots/", |
| 79 | []string{"lowerdir=1/fs:10/fs"}, |
| 80 | }, |
| 81 | { |
| 82 | []string{"lowerdir=/snapshots/1/fs:/snapshots/10/fs:/snapshots/2/fs"}, |
| 83 | "/snapshots/", |
| 84 | []string{"lowerdir=1/fs:10/fs:2/fs"}, |
| 85 | }, |
| 86 | |
| 87 | // if common dir is / |
| 88 | { |
| 89 | []string{"lowerdir=/snapshots/1/fs:/other_snapshots/1/fs"}, |
| 90 | "", |
| 91 | []string{"lowerdir=/snapshots/1/fs:/other_snapshots/1/fs"}, |
| 92 | }, |
| 93 | |
| 94 | // if common dir is . |
| 95 | { |
| 96 | []string{"lowerdir=a:aaa"}, |
| 97 | "", |
| 98 | []string{"lowerdir=a:aaa"}, |
| 99 | }, |
| 100 | } |
| 101 | |
| 102 | for i, tc := range tcases { |
| 103 | dir, opts := compactLowerdirOption(tc.opts) |
| 104 | if dir != tc.commondir { |
| 105 | t.Fatalf("[%d case] expected common dir (%s), but got (%s)", i+1, tc.commondir, dir) |
| 106 | } |
| 107 | |
| 108 | if !reflect.DeepEqual(opts, tc.newopts) { |
| 109 | t.Fatalf("[%d case] expected options (%v), but got (%v)", i+1, tc.newopts, opts) |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | func TestFUSEHelper(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…