Skip to content

Commit f5871e4

Browse files
committed
Fixup! some tests should be better now.
1 parent b5d7b39 commit f5871e4

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

LibGit2Sharp.Tests/StashFixture.cs

+14-7
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,17 @@ public void CanStashAndPop()
213213
var stasher = Constants.Signature;
214214

215215
const string filename = "staged_file_path.txt";
216-
Touch(repo.Info.WorkingDirectory, filename, "I'm staged\n");
216+
const string contents = "I'm staged\n";
217+
string contentsNew = "I'm staged" + Environment.NewLine;
218+
Touch(repo.Info.WorkingDirectory, filename, contents);
217219
repo.Stage(filename);
218220

219221
repo.Stashes.Add(stasher, "This stash with default options");
220222
Assert.Equal(StashApplyStatus.Applied, repo.Stashes.Pop(0));
221223

222224
Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus(filename));
223225
Assert.Equal(0, repo.Stashes.Count());
226+
Assert.Equal(contentsNew, File.ReadAllText(Path.Combine(repo.Info.WorkingDirectory, filename)));
224227
}
225228
}
226229

@@ -233,21 +236,25 @@ public void StashReportsConflictsWhenReinstated()
233236
var stasher = Constants.Signature;
234237

235238
const string filename = "staged_file_path.txt";
239+
const string originalContents = "I'm pre-stash.";
236240
const string filename2 = "unstaged_file_path.txt";
237-
Touch(repo.Info.WorkingDirectory, filename, "I'm staged\n");
241+
const string newContents = "I'm post-stash.";
242+
243+
Touch(repo.Info.WorkingDirectory, filename, originalContents);
238244
repo.Stage(filename);
239-
Touch(repo.Info.WorkingDirectory, filename2, "I'm unstaged\n");
245+
Touch(repo.Info.WorkingDirectory, filename2, originalContents);
240246

241247
repo.Stashes.Add(stasher, "This stash with default options");
242248

243-
Touch(repo.Info.WorkingDirectory, filename, "I'm another staged\n");
249+
Touch(repo.Info.WorkingDirectory, filename, newContents);
244250
repo.Stage(filename);
245-
Touch(repo.Info.WorkingDirectory, filename2, "I'm unstaged another staged\n");
251+
Touch(repo.Info.WorkingDirectory, filename2, newContents);
246252

247253
Assert.Equal(StashApplyStatus.Conflicts, repo.Stashes.Pop(0, StashApplyModifiers.ReinstateIndex));
254+
Assert.Equal(1, repo.Stashes.Count());
255+
Assert.Equal(originalContents, File.ReadAllText(Path.Combine(repo.Info.WorkingDirectory, filename)));
256+
Assert.Equal(originalContents, File.ReadAllText(Path.Combine(repo.Info.WorkingDirectory, filename2)));
248257

249-
// TODO: Find out why repo.Index.Conflicts doesn't have any data.
250-
Assert.NotNull(repo.Index.Conflicts[filename]);
251258
}
252259
}
253260

0 commit comments

Comments
 (0)