How to turn off Multi Tenant Single DB plugin for testing or solve the issue of no tenant is set

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to turn off Multi Tenant Single DB plugin for testing or solve the issue of no tenant is set

sryan
I am trying to run my tests using the Multi Tenant Single DB plugin and getting the following failure:

grails.plugin.multitenant.core.exception.NoCurrentTenantException: Tried to save multi-tenant domain class 'People', but no tenant is set

I assume the error is because I am testing my service and not going through a URL to trigger the tenant resolver.    Is there a way I can turn off the plugin during testing ora way I can wire up a tenant so the tests will run.  I assume this is a common problem with a simple solution.

Thanks


Scott Ryan
Software Developer


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: How to turn off Multi Tenant Single DB plugin for testing or solve the issue of no tenant is set

lucastex
Hi Scott,

You can wrap the code around

YourTenantClass.withTenantId(x) {

}



On Wed, Mar 20, 2013 at 12:37 PM, Scott Ryan <[hidden email]> wrote:
I am trying to run my tests using the Multi Tenant Single DB plugin and getting the following failure:

grails.plugin.multitenant.core.exception.NoCurrentTenantException: Tried to save multi-tenant domain class 'People', but no tenant is set

I assume the error is because I am testing my service and not going through a URL to trigger the tenant resolver.    Is there a way I can turn off the plugin during testing ora way I can wire up a tenant so the tests will run.  I assume this is a common problem with a simple solution.

Thanks


Scott Ryan
Software Developer


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: How to turn off Multi Tenant Single DB plugin for testing or solve the issue of no tenant is set

sryan
Yes that would work but I have over 1000 tests and I hate to modify my code to use the multi tenant plugin and then have to un modify it if I change.   The old one had a way to turn it off for testing but I don't see that setting in the single DB one.  I tried to use the before test annotation but you have to wrap the entire test and that did not work   I wanted a good way to to do this but I could also hack the internal code to return a fixed tenant id for testing but hate to do that.

I commented out the plugin in BuildConfig and that worked so I could do that but that is way to manual

Scott Ryan
Software Developer


From: "Lucas F. A. Teixeira" <[hidden email]<mailto:[hidden email]>>
Reply-To: "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Date: Wednesday, March 20, 2013 11:03 AM
To: lista grails-user <[hidden email]<mailto:[hidden email]>>
Subject: Re: [grails-user] How to turn off Multi Tenant Single DB plugin for testing or solve the issue of no tenant is set

Hi Scott,

You can wrap the code around

YourTenantClass.withTenantId(x) {

}

Lucas Teixeira<http://about.me/lucastex>


On Wed, Mar 20, 2013 at 12:37 PM, Scott Ryan <[hidden email]<mailto:[hidden email]>> wrote:
I am trying to run my tests using the Multi Tenant Single DB plugin and getting the following failure:

grails.plugin.multitenant.core.exception.NoCurrentTenantException: Tried to save multi-tenant domain class 'People', but no tenant is set

I assume the error is because I am testing my service and not going through a URL to trigger the tenant resolver.    Is there a way I can turn off the plugin during testing ora way I can wire up a tenant so the tests will run.  I assume this is a common problem with a simple solution.

Thanks


Scott Ryan
Software Developer


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: How to turn off Multi Tenant Single DB plugin for testing or solve the issue of no tenant is set

alxndrsn
On 20 March 2013 20:13, Scott Ryan <[hidden email]> wrote:
> I commented out the plugin in BuildConfig and that worked so I could do that but that is way to manual

You could automate that in Events.groovy with

    eventTestSuiteStart { phase -> ... }

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email