I need to store connection strings and other settings in my .NET Core 2.0 integration tests. How can I do this safely considering those tests run locally and in VSTS? Ideally, I need those settings separate for local environment and running on VSTS.
mercredi 25 octobre 2017
Power Cycling Task Automation with Python
I was recenetly given a project to create a stand alone program that administer power cycling task automation using Python with a mac and then verify the plugged in devices.
The program is straight forward- It would sleep, restart, or hybernate the device for however many times you wish and after each cycle it would check all the devices that are plugged in and make sure everything is still plugged in properly.
For example, I would have the program sleep and wake my machine 5 times. First the program would take a "snapshot" of what devices are plugged into the machine and then after each sleep and wake the progam would take another "snapshot" and compare it to the original to verify all devices.
I am not really a python professional or Mac guy so I am kind of unsure of where to start here. So any and all help would be appreciated.
Thanks!
fakeAsync instead of async testing angular two-way binding
I got a test for this textarea in my component:
<textarea [(ngModel)]="result"></textarea>
And a working test using async:
it('Using async', async(() => {
const result = fixture.debugElement.query(By.css('textarea'));
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(result.nativeElement.value).toBe('Value');
});
}));
This works fine. But I'm trying to do the same with fakeAsync it doesn't work:
it('Using fakeAsync', fakeAsync(() => {
const result = fixture.debugElement.query(By.css('textarea'));
fixture.detectChanges();
tick();
expect(component.result).toBe('Patata'); //--> This works fine
expect(result.nativeElement.value).toBe('Patata'); //-->this doesn't
}));
Can you help me? Thank you!
Mocking NewConsumer in sarama-cluster
Is there a way to test/mock sarama-cluster's NewConsumer function without having actual brokers set up? What am I missing here?
Code I'm trying to test:
import cluster "http://ift.tt/1TgZOro"
func initSaramaConsumer() (*cluster.Consumer, err) {
brokers := []string{"some_url:port"}
groups := []string{"some_group"}
topics := []string{"some_topic"}
config := cluster.NewConfig()
saramaConsumer, err := cluster.NewConsumer(
brokers, groups, topics, config,
)
if err != nil {
return nil, err
}
return saramaConsumer, nil
}
Mock function elixir
I have a function like this
def foo_bar() do
Enum.reduce_while(
image_options,
0,
fn image_option, _foo ->
case image_option["destination"] do
"s3" ->
case response = Upload.upload_on_s3(foo, bar) do
{:ok, _} ->
{:cont, {:ok, "ok"}}
{:error, _} ->
{:halt, response}
end
_ ->
{:cont, {:ok, "todo"}}
end
end
)
end
I want to test foo_bar in unit test. How can I mock Upload.upload_on_s3(foo, bar) function?
Connecting to websphere MQ using ruby
I need to push a message to MQ from ruby code. The only gem I see is WMQ and I don't think that works on OSX systems (mine is a remote MQ)
What are options I have? I can't find any details on this online
Rspec models not from codebase
I'm wondering if anyone could shed some light on the best way to test code that works with database models, but does not care what that model is.
Our app has a kind of synchronisation engine that keeps data on a remote server in sync with data on our system, and operates on a number of database models. It is also designed to work with multiple remote systems, and as such contains a number of internal data models which later get mapped to our actual database records.
As an example, we have something like this:
class RemoteResource < Syncable
maps_to ::InternalDbModel
....
end
Here, the sync engine would pull data from any of the remote servers and convert it into a RemoteResource instance, and later this would get translated into an InternalDbModel for persistence.
Due to the generic design, the sync engine doesn't care what database models it is converting to. So long as they meet certain criteria, they are valid.
My question revolves around testing this sort of code. Due to time constraints, I've had to write tests that I simply don't like - the tests involve creating records of actual models used by the app, but I don't like this for a number of reasons:
- Each test has to know about the model in order to create the records
- If the model has other requirements, they must be fulfilled first, which is completely irrelevant for the test itself
- It is not the model that I want to test
The syncable class is fine, as I am able to simply stub a class in the test and that works fine. But how can I do something similar for the active record model? Is there a way that I can create a kind of anonymous model class for these kind of tests? I will need to be able to persist the data as some of the sync engine process tests will require that data already exists, but i want this data to be completely independent of the main app itself.
I hope this makes sense