public void Error_if_script_has_both_apply_to_all_documents_and_collections_specified() { var config = new RavenEtlConfiguration { Name = "test", ConnectionStringName = "test", Transforms = { new Transformation { Name = "test", ApplyToAllDocuments = true, Collections = { "Users" } } } }; config.Initialize(new RavenConnectionString() { Database = "Foo", TopologyDiscoveryUrls = new[] { "http://localhost:8080" } }); List <string> errors; config.Validate(out errors); Assert.Equal(1, errors.Count); Assert.Equal("Collections cannot be specified when ApplyToAllDocuments is set", errors[0]); }
public void Can_put_space_after_loadTo_method_in_script() { var config = new RavenEtlConfiguration { Name = "test", ConnectionStringName = "test", Transforms = { new Transformation { Name = "test", Collections ={ "Users" }, Script = @"loadToUsers (this);" } } }; config.Initialize(new RavenConnectionString() { Database = "Foo", TopologyDiscoveryUrls = new [] { "http://localhost:8080" } }); List <string> errors; config.Validate(out errors); Assert.Equal(0, errors.Count); var collections = config.Transforms[0].GetCollectionsFromScript(); Assert.Equal(1, collections.Length); Assert.Equal("Users", collections[0]); }
public void Error_if_script_does_not_contain_any_loadTo_method() { var config = new RavenEtlConfiguration { Name = "test", ConnectionStringName = "test", Transforms = { new Transformation { Name = "test", Collections ={ "Users" }, Script = @"this.Name = 'aaa';" } } }; config.Initialize(new RavenConnectionString() { Database = "Foo", TopologyDiscoveryUrls = new[] { "http://localhost:8080" } }); List <string> errors; config.Validate(out errors); Assert.Equal(1, errors.Count); Assert.Equal("No `loadTo[CollectionName]` method call found in 'test' script", errors[0]); }
public void Should_throw_when_transforms_is_empty() { var configuration = new RavenEtlConfiguration { ConnectionStringName = "test", Name = "myConfig", MentorNode = "A", Transforms = new List <Transformation>() }; configuration.Initialize(new RavenConnectionString()); var e = Assert.Throws <InvalidOperationException>(() => configuration.Validate(out List <string> _)); Assert.Equal($"'{nameof(RavenEtlConfiguration.Transforms)}' list cannot be empty.", e.Message); }
public void Error_if_script_does_not_contain_any_loadTo_method_and_isnt_empty() { var config = new RavenEtlConfiguration { Name = "test", ConnectionStringName = "test", Transforms = { new Transformation { Name = "test", Collections ={ "Users" }, Script = @" this.Name = 'aaa'; // we have some modification but we don't call loadTo method so it should error function deleteDocumentsOfUsersBehavior(docId) { return false; } " } } }; config.Initialize(new RavenConnectionString() { Database = "Foo", TopologyDiscoveryUrls = new[] { "http://localhost:8080" } }); List <string> errors; config.Validate(out errors); Assert.Equal(1, errors.Count); Assert.Equal("No `loadTo<CollectionName>()` method call found in 'test' script", errors[0]); }