| 128 | } |
| 129 | |
| 130 | func checkStashes(t *testing.T, repo *Repository, expected []stash) { |
| 131 | var actual []stash |
| 132 | |
| 133 | repo.Stashes.Foreach(func(index int, msg string, id *Oid) error { |
| 134 | stash := stash{index, msg, id.String()} |
| 135 | if len(expected) > len(actual) { |
| 136 | if s := expected[len(actual)]; s.id == "" { |
| 137 | stash.id = "" // don't check id |
| 138 | } |
| 139 | } |
| 140 | actual = append(actual, stash) |
| 141 | return nil |
| 142 | }) |
| 143 | |
| 144 | if len(expected) > 0 && !reflect.DeepEqual(expected, actual) { |
| 145 | // The failure happens at wherever we were called, not here |
| 146 | _, file, line, ok := runtime.Caller(1) |
| 147 | if !ok { |
| 148 | t.Fatalf("Unable to get caller") |
| 149 | } |
| 150 | t.Errorf("%v:%v: expecting %#v\ngot %#v", path.Base(file), line, expected, actual) |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | func prepareStashRepo(t *testing.T, repo *Repository) { |
| 155 | seedTestRepo(t, repo) |