public void can_write_ddl_by_type_smoke_test_for_document_creation() { using (var store = DocumentStore.For(_ => { _.RegisterDocumentType<User>(); _.RegisterDocumentType<Company>(); _.RegisterDocumentType<Issue>(); _.Connection(ConnectionSource.ConnectionString); })) { store.Schema.WriteDDLByType("allsql"); } var fileSystem = new FileSystem(); var files = fileSystem.FindFiles("allsql", FileSet.Shallow("*.sql")).ToArray(); files.Select(Path.GetFileName) .Where(x => x != "all.sql" && x != "database_schemas.sql").OrderBy(x => x) .ShouldHaveTheSameElementsAs("company.sql", "issue.sql", "mt_hilo.sql", "user.sql"); files.Each(file => { var contents = fileSystem.ReadStringFromFile(file); contents.ShouldContain("CREATE TABLE"); contents.ShouldContain("CREATE OR REPLACE FUNCTION"); }); }
public void copy_directory() { var system = new FileSystem(); system.ResetDirectory("dagobah"); system.WriteStringToFile("dagobah".AppendPath("f1", "a.txt"), "something"); system.WriteStringToFile("dagobah".AppendPath("f2", "a.txt"), "something"); system.WriteStringToFile("dagobah".AppendPath("f3", "a.txt"), "something"); system.WriteStringToFile("dagobah".AppendPath("f1", "f1a", "a.txt"), "something"); system.WriteStringToFile("dagobah".AppendPath("f1", "f1a", "f1b", "a.txt"), "something"); system.WriteStringToFile("dagobah".AppendPath("a.txt"), "something"); system.DeleteDirectory("rhenvar"); system.Copy("dagobah", "rhenvar"); system.FindFiles("rhenvar", FileSet.Everything()).Select(x => x.PathRelativeTo("rhenvar")).OrderBy(x => x) .ShouldHaveTheSameElementsAs( "a.txt", FileSystem.Combine("f1", "a.txt"), FileSystem.Combine("f1", "f1a", "a.txt"), FileSystem.Combine("f1", "f1a", "f1b", "a.txt"), FileSystem.Combine("f2", "a.txt"), FileSystem.Combine("f3", "a.txt") ); }
/// <summary> /// Read [name].table and [name].function files from the named directory /// to serve as templates for extra DDL (GRANT's probably) /// </summary> /// <param name="directory"></param> public void ReadTemplates(string directory) { var system = new FileSystem(); system.FindFiles(directory, FileSet.Shallow("*.function")).Each(file => { var name = Path.GetFileNameWithoutExtension(file).ToLower(); Templates[name].FunctionCreation = system.ReadStringFromFile(file); }); system.FindFiles(directory, FileSet.Shallow("*.table")).Each(file => { var name = Path.GetFileNameWithoutExtension(file).ToLower(); Templates[name].TableCreation = system.ReadStringFromFile(file); }); }
public void CleanTarget(string directory) { var fileSystem = new FileSystem(); foreach (var child in Directory.GetDirectories(directory)) { if (child.Contains(".git")) continue; fileSystem.DeleteDirectory(child); } fileSystem.FindFiles(directory, FileSet.Shallow("*.htm")) .Each(fileSystem.DeleteFile); }
public void LoadProjections(string directory) { var files = new FileSystem(); using (var connection = new ManagedConnection(_connectionFactory)) { files.FindFiles(directory, FileSet.Deep("*.js")).Each(file => { var body = files.ReadStringFromFile(file); var name = Path.GetFileNameWithoutExtension(file); connection.Execute(cmd => { cmd.CallsSproc(qualifyName("mt_load_projection_body")) .With("proj_name", name) .With("body", body) .ExecuteNonQuery(); }); }); } }
public static Recipe ReadFrom(string recipeDirectory) { var recipeName = Path.GetFileName(recipeDirectory); var recipe = new Recipe(recipeName); var fileSystem = new FileSystem(); fileSystem.ReadTextFile(recipeDirectory.AppendPath(Milkman.ProfileFiles.RecipesControlFile), s => { //TODO: Harden this for bad syntax var parts = s.Split(':'); recipe.RegisterDependency(parts[1]); }); fileSystem.FindFiles(recipeDirectory, new FileSet(){ Include = "*.host" }).Each(file => { var host = HostReader.ReadFrom(file); recipe.RegisterHost(host); }); return recipe; }
public void write_ddl_by_type_with_events() { using (var store = DocumentStore.For(_ => { _.RegisterDocumentType<User>(); _.RegisterDocumentType<Company>(); _.RegisterDocumentType<Issue>(); _.Events.AddAggregateType<Quest>(); _.Connection(ConnectionSource.ConnectionString); })) { store.Schema.Events.IsActive.ShouldBeTrue(); store.Schema.WriteDDLByType("allsql"); } var fileSystem = new FileSystem(); fileSystem.FindFiles("allsql", FileSet.Shallow("*mt_streams.sql")) .Any().ShouldBeTrue(); }
public void write_ddl_by_type_with_events() { using (var store = DocumentStore.For(_ => { _.RegisterDocumentType<User>(); _.RegisterDocumentType<Company>(); _.RegisterDocumentType<Issue>(); _.Events.AddEventType(typeof(MembersJoined)); _.Connection(ConnectionSource.ConnectionString); })) { store.Schema.Events.IsActive.ShouldBeTrue(); store.Schema.WriteDDLByType(@"bin\allsql"); } var fileSystem = new FileSystem(); fileSystem.FindFiles(@"bin\allsql", FileSet.Shallow("eventstore.sql")) .Any().ShouldBeTrue(); }
public void can_write_ddl_by_type_with_no_database_connection() { using (var store = DocumentStore.For(_ => { _.RegisterDocumentType<User>(); _.RegisterDocumentType<Company>(); _.RegisterDocumentType<Issue>(); _.AutoCreateSchemaObjects = AutoCreate.None; _.Connection(""); })) { store.Schema.Events.IsActive.ShouldBeFalse(); store.Schema.WriteDDLByType(@"bin\allsql"); } var fileSystem = new FileSystem(); fileSystem.FindFiles(@"bin\allsql", FileSet.Shallow("*mt_streams.sql")) .Any().ShouldBeFalse(); }
public void can_write_patch_by_type_smoke_test() { using (var store = DocumentStore.For(_ => { _.RegisterDocumentType<User>(); _.RegisterDocumentType<Company>(); _.RegisterDocumentType<Issue>(); _.Connection(ConnectionSource.ConnectionString); })) { store.Advanced.Clean.CompletelyRemoveAll(); store.Schema.WritePatchByType(@"bin\allsql2"); } var fileSystem = new FileSystem(); var files = fileSystem.FindFiles(@"bin\allsql2", FileSet.Shallow("*.sql")).ToArray(); files.ShouldNotContain("database_schemas.sql"); files.Select(Path.GetFileName).Where(x => x != "all.sql").OrderBy(x => x) .ShouldHaveTheSameElementsAs("company.sql", "issue.sql", "mt_hilo.sql", "patch_doc.sql", "user.sql"); }
private static IEnumerable<ProjectDependency> readRippleDependencies(string directory) { var fileSystem = new FileSystem(); var projectFiles = fileSystem.FindFiles(directory, FileSet.Deep("*.csproj")); return projectFiles.SelectMany(file => { var projectName = Path.GetFileNameWithoutExtension(file); IList<string> names = null; fileSystem.AlterFlatFile(file.ParentDirectory().AppendPath(RippleDependenciesConfig), list => names = list.Where(x => x.IsNotEmpty()).ToList()); return names.Select(x => new ProjectDependency {Nuget = x, Project = projectName}); }); }
private static IEnumerable<string> findRippleFiles(string directory) { var fileSystem = new FileSystem(); var list = fileSystem.FindFiles(directory, FileSet.Deep("ripple.dependencies.config")).ToList(); var rippleMain = directory.AppendPath("ripple.config"); list.Add(rippleMain); return list; }
public void LoadProjections(string directory) { _schema.EnsureStorageExists(typeof(EventStream)); var files = new FileSystem(); using (var connection = new ManagedConnection(_connectionFactory)) { files.FindFiles(directory, FileSet.Deep("*.js")).Each(file => { var body = files.ReadStringFromFile(file); var name = Path.GetFileNameWithoutExtension(file); connection.Execute(cmd => { cmd.CallsSproc(LoadProjectionBodyFunction) .With("proj_name", name) .With("body", body) .ExecuteNonQuery(); }); }); } }
public IEnumerable<string> FindFiles(FileSet files) { var system = new FileSystem(); return _directories.SelectMany(dir => system.FindFiles(dir, files)); }
public void fixing_bug_343_double_export_of_events() { using (var store = DocumentStore.For(_ => { _.RegisterDocumentType<User>(); _.RegisterDocumentType<Company>(); _.RegisterDocumentType<Issue>(); _.Events.AddEventType(typeof(MembersJoined)); _.Connection(ConnectionSource.ConnectionString); })) { store.Schema.Events.IsActive.ShouldBeTrue(); store.Schema.WriteDDLByType(_binAllsql); } var fileSystem = new FileSystem(); fileSystem.FindFiles(_binAllsql, FileSet.Shallow(".sql")) .Any().ShouldBeFalse(); }