eden/fs/inodes/test/DiffTest.cpp
// Test making modifications to the .gitignore file
Test making modifications to the .gitignore file
Test making modifications to the . gitignore file
TEST(DiffTest, ignoreFileModified) {
  DiffTest test({
      {"a/.gitignore", "foo.txt\n"},
  });
  test.getMount().addFile("a/foo.txt", "test\n");
  test.getMount().addFile("a/bar.txt", "test\n");
  test.getMount().addFile("a/test.txt", "test\n");
  auto result = test.diff(true);
  EXPECT_THAT(result.getErrors(), UnorderedElementsAre());
  EXPECT_THAT(
      result.getUntracked(),
      UnorderedElementsAre(
          RelativePath{"a/bar.txt"}, RelativePath{"a/test.txt"}));
  EXPECT_THAT(
      result.getIgnored(), UnorderedElementsAre(RelativePath{"a/foo.txt"}));
  EXPECT_THAT(result.getRemoved(), UnorderedElementsAre());
  EXPECT_THAT(result.getModified(), UnorderedElementsAre());
  test.getMount().overwriteFile("a/.gitignore", "bar.txt\n");
  result = test.diff(true);
  EXPECT_THAT(result.getErrors(), UnorderedElementsAre());
  EXPECT_THAT(
      result.getUntracked(),
      UnorderedElementsAre(
          RelativePath{"a/foo.txt"}, RelativePath{"a/test.txt"}));
  EXPECT_THAT(
      result.getIgnored(), UnorderedElementsAre(RelativePath{"a/bar.txt"}));
  EXPECT_THAT(result.getRemoved(), UnorderedElementsAre());
  EXPECT_THAT(
      result.getModified(), UnorderedElementsAre(RelativePath{"a/.gitignore"}));
  test.getMount().addFile(".gitignore", "test.txt\n");
  result = test.diff(true);
  EXPECT_THAT(result.getErrors(), UnorderedElementsAre());
  EXPECT_THAT(
      result.getUntracked(),
      UnorderedElementsAre(
          RelativePath{".gitignore"}, RelativePath{"a/foo.txt"}));
  EXPECT_THAT(
      result.getIgnored(),
      UnorderedElementsAre(
          RelativePath{"a/bar.txt"}, RelativePath{"a/test.txt"}));
  EXPECT_THAT(result.getRemoved(), UnorderedElementsAre());
  EXPECT_THAT(
      result.getModified(), UnorderedElementsAre(RelativePath{"a/.gitignore"}));
}
TEST ( DiffTest , ignoreFileModified ) { DiffTest test ( { { " " , " \n " } , } ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; auto result = test . diff ( true ) ; EXPECT_THAT ( result . getErrors ( ) , UnorderedElementsAre ( ) ) ; EXPECT_THAT ( result . getUntracked ( ) , UnorderedElementsAre ( RelativePath { " " } , RelativePath { " " } ) ) ; EXPECT_THAT ( result . getIgnored ( ) , UnorderedElementsAre ( RelativePath { " " } ) ) ; EXPECT_THAT ( result . getRemoved ( ) , UnorderedElementsAre ( ) ) ; EXPECT_THAT ( result . getModified ( ) , UnorderedElementsAre ( ) ) ; test . getMount ( ) . overwriteFile ( " " , " \n " ) ; result = test . diff ( true ) ; EXPECT_THAT ( result . getErrors ( ) , UnorderedElementsAre ( ) ) ; EXPECT_THAT ( result . getUntracked ( ) , UnorderedElementsAre ( RelativePath { " " } , RelativePath { " " } ) ) ; EXPECT_THAT ( result . getIgnored ( ) , UnorderedElementsAre ( RelativePath { " " } ) ) ; EXPECT_THAT ( result . getRemoved ( ) , UnorderedElementsAre ( ) ) ; EXPECT_THAT ( result . getModified ( ) , UnorderedElementsAre ( RelativePath { " " } ) ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; result = test . diff ( true ) ; EXPECT_THAT ( result . getErrors ( ) , UnorderedElementsAre ( ) ) ; EXPECT_THAT ( result . getUntracked ( ) , UnorderedElementsAre ( RelativePath { " " } , RelativePath { " " } ) ) ; EXPECT_THAT ( result . getIgnored ( ) , UnorderedElementsAre ( RelativePath { " " } , RelativePath { " " } ) ) ; EXPECT_THAT ( result . getRemoved ( ) , UnorderedElementsAre ( ) ) ; EXPECT_THAT ( result . getModified ( ) , UnorderedElementsAre ( RelativePath { " " } ) ) ; }
Test making modifications to the .gitignore file
Test making modifications to the . gitignore file
// Changes to the gitignore file should take effect immediately // Newly added gitignore files should also take effect immediately