Package com.google.devtools.moe.client.testing

Examples of com.google.devtools.moe.client.testing.InMemoryFileSystem


  /**
   * Bookkeeping for codebases the same at head, different at migrated revs.
   */
  public void testHeadsEquivalent() throws Exception {
    InMemoryFileSystem fileSystem = new InMemoryFileSystem(ImmutableMap.of(
        "/path/to/db", "{\"equivalences\":[], \"migrations\":[]}",
        "/dummy/codebase/int/1/file", "1",
        "/dummy/codebase/pub/1/file", "1 (equivalent)",
        "/dummy/codebase/int/migrated_from/file", "migrated_from",
        "/dummy/codebase/pub/migrated_to/", "dir (different)"
        ));
    AppContext.RUN.fileSystem = fileSystem;

    BookkeepingDirective d = new BookkeepingDirective();
    d.getFlags().configFilename = "moe_config.txt";
    d.getFlags().dbLocation = DB_FILE.getAbsolutePath();

    expectDiffs();

    control.replay();
    assertEquals(0, d.perform());
    control.verify();

    // expected db at end of call to bookkeep
    DbStorage dbStorage = new DbStorage();
    dbStorage.addEquivalence(new Equivalence(new Revision("1", "int"), new Revision("1", "pub")));
    dbStorage.addMigration(new SubmittedMigration(
        new Revision("migrated_from", "int"), new Revision("migrated_to", "pub")));
    FileDb expectedDb = new FileDb(dbStorage);

    assertEquals(expectedDb.toJsonString(), fileSystem.fileToString(DB_FILE));
  }
View Full Code Here


  /**
   * Bookkeeping for codebases different at head and migrated revs.
   */
  public void testOneSubmittedMigration_nonEquivalent() throws Exception {
    InMemoryFileSystem fileSystem = new InMemoryFileSystem(ImmutableMap.of(
        "/path/to/db", "{\"equivalences\":[], \"migrations\":[]}",
        "/dummy/codebase/int/1/file", "1",
        "/dummy/codebase/pub/1/", "empty dir (different)",
        "/dummy/codebase/int/migrated_from/file", "migrated_from",
        "/dummy/codebase/pub/migrated_to/", "empty dir (different)"
        ));
    AppContext.RUN.fileSystem = fileSystem;

    BookkeepingDirective d = new BookkeepingDirective();
    d.getFlags().configFilename = "moe_config.txt";
    d.getFlags().dbLocation = DB_FILE.getAbsolutePath();

    expectDiffs();

    control.replay();
    assertEquals(0, d.perform());
    control.verify();

    // expected db at end of call to bookkeep
    DbStorage dbStorage = new DbStorage();
    dbStorage.addMigration(new SubmittedMigration(
        new Revision("migrated_from", "int"), new Revision("migrated_to", "pub")));
    FileDb expectedDb = new FileDb(dbStorage);

    assertEquals(expectedDb.toJsonString(), fileSystem.fileToString(DB_FILE));
  }
View Full Code Here

  /**
   * Bookkeeping for codebases different at head and equivalent at migrated revs.
   */
  public void testOneSubmittedMigration_equivalent() throws Exception {
    InMemoryFileSystem fileSystem = new InMemoryFileSystem(ImmutableMap.of(
        "/path/to/db", "{\"equivalences\":[], \"migrations\":[]}",
        "/dummy/codebase/int/1/file", "1",
        "/dummy/codebase/pub/1/", "empty dir (different)",
        "/dummy/codebase/int/migrated_from/file", "migrated_from",
        "/dummy/codebase/pub/migrated_to/file", "migrated_to (equivalent)"
        ));
    AppContext.RUN.fileSystem = fileSystem;

    BookkeepingDirective d = new BookkeepingDirective();
    d.getFlags().configFilename = "moe_config.txt";
    d.getFlags().dbLocation = DB_FILE.getAbsolutePath();

    expectDiffs();

    control.replay();
    assertEquals(0, d.perform());
    control.verify();

    // expected db at end of call to bookkeep
    DbStorage dbStorage = new DbStorage();
    dbStorage.addEquivalence(new Equivalence(
        new Revision("migrated_from", "int"), new Revision("migrated_to", "pub")));
    dbStorage.addMigration(new SubmittedMigration(
        new Revision("migrated_from", "int"), new Revision("migrated_to", "pub")));
    FileDb expectedDb = new FileDb(dbStorage);

    assertEquals(expectedDb.toJsonString(), fileSystem.fileToString(DB_FILE));
  }
View Full Code Here

TOP

Related Classes of com.google.devtools.moe.client.testing.InMemoryFileSystem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.