eden/fs/inodes/test/DiffTest.cpp
// Test when files already tracked in source control match ignore patterns
Test when files already tracked in source control match ignore patterns
Test when files already tracked in source control match ignore patterns
TEST(DiffTest, explicitlyTracked) {
  DiffTest test({
      {".gitignore", "1.txt\njunk\n"},
      {"junk/a/b/c.txt", "test\n"},
      {"junk/a/b/d.txt", "test\n"},
      {"junk/x/foo.txt", "test\n"},
      {"src/1.txt", "test\n"},
      {"docs/test.txt", "test\n"},
  });
  test.getMount().addFile("docs/1.txt", "new\n");
  test.getMount().addFile("junk/foo.txt", "new\n");
  test.getMount().addFile("junk/test.txt", "new\n");
  test.getMount().addFile("junk/a/b/xyz.txt", "new\n");
  test.getMount().addFile("other.txt", "new\n");
  test.getMount().overwriteFile("junk/a/b/c.txt", "new\n");
  test.getMount().deleteFile("junk/x/foo.txt");
  auto result = test.diff();
  EXPECT_THAT(result.getErrors(), UnorderedElementsAre());
  EXPECT_THAT(
      result.getUntracked(), UnorderedElementsAre(RelativePath{"other.txt"}));
  EXPECT_THAT(result.getIgnored(), UnorderedElementsAre());
  EXPECT_THAT(
      result.getRemoved(),
      UnorderedElementsAre(RelativePath{"junk/x/foo.txt"}));
  EXPECT_THAT(
      result.getModified(),
      UnorderedElementsAre(RelativePath{"junk/a/b/c.txt"}));
  result = test.diff(true);
  EXPECT_THAT(result.getErrors(), UnorderedElementsAre());
  EXPECT_THAT(
      result.getUntracked(), UnorderedElementsAre(RelativePath{"other.txt"}));
  EXPECT_THAT(
      result.getIgnored(),
      UnorderedElementsAre(
          RelativePath{"docs/1.txt"},
          RelativePath{"junk/foo.txt"},
          RelativePath{"junk/test.txt"},
          RelativePath{"junk/a/b/xyz.txt"}));
  EXPECT_THAT(
      result.getRemoved(),
      UnorderedElementsAre(RelativePath{"junk/x/foo.txt"}));
  EXPECT_THAT(
      result.getModified(),
      UnorderedElementsAre(RelativePath{"junk/a/b/c.txt"}));
}
TEST ( DiffTest , explicitlyTracked ) { DiffTest test ( { { " " , " \n \n " } , { " " , " \n " } , { " " , " \n " } , { " " , " \n " } , { " " , " \n " } , { " " , " \n " } , } ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . overwriteFile ( " " , " \n " ) ; test . getMount ( ) . deleteFile ( " " ) ; auto result = test . diff ( ) ; EXPECT_THAT ( result . getErrors ( ) , UnorderedElementsAre ( ) ) ; EXPECT_THAT ( result . getUntracked ( ) , UnorderedElementsAre ( RelativePath { " " } ) ) ; EXPECT_THAT ( result . getIgnored ( ) , UnorderedElementsAre ( ) ) ; EXPECT_THAT ( result . getRemoved ( ) , UnorderedElementsAre ( RelativePath { " " } ) ) ; EXPECT_THAT ( result . getModified ( ) , UnorderedElementsAre ( RelativePath { " " } ) ) ; result = test . diff ( true ) ; EXPECT_THAT ( result . getErrors ( ) , UnorderedElementsAre ( ) ) ; EXPECT_THAT ( result . getUntracked ( ) , UnorderedElementsAre ( RelativePath { " " } ) ) ; EXPECT_THAT ( result . getIgnored ( ) , UnorderedElementsAre ( RelativePath { " " } , RelativePath { " " } , RelativePath { " " } , RelativePath { " " } ) ) ; EXPECT_THAT ( result . getRemoved ( ) , UnorderedElementsAre ( RelativePath { " " } ) ) ; EXPECT_THAT ( result . getModified ( ) , UnorderedElementsAre ( RelativePath { " " } ) ) ; }
Test when files already tracked in source control match ignore patterns
Test when files already tracked in source control match ignore patterns