How to assert with a debug message in Go tests? - go

I want to do this:
test.FailNow("My Message")
but test.T.FailNow doesn't take a message. I am currently doing:
log.Println("Expected exception but got none")
test.FailNow()
Is there a better way?

See: http://golang.org/pkg/testing/#T.Fatal (and Fatalf)
The docs say: "Fatal is equivalent to Log() followed by FailNow()."

I build a little helping package as part of my Tideland Common Go Library (see http://code.google.com/p/tcgl/). The API doc can found at http://go.pkgdoc.org/code.google.com/p/tcgl/asserts.

Related

google's notebook on vertex ai throwing following error: type name google.VertexModel is different from expected: Model

I got this error, when compiling my pipeline:
type name google.VertexModel is different from expected: Model
when running the following notebook by google: automl_tabular_classification_beans
I suppose that kubeflow v2 is not able to handle (yet) google.vertexmodel as type for component input. However, I've been browsing a bit and did not find any good clue, or refs (kfp documentation for v2 is not up to date..) to solve this issue. Hopefully someone here can give me a good pointer? I look forward to all of your ideas.
Cheers
Google.Vertex is defined here:
https://github.com/kubeflow/pipelines/blob/286a49547cce763c502592c822296aa60f50b3e8/components/google-cloud/google_cloud_pipeline_components/types/artifact_types.py#L20
Here is an example on how to define it:
https://github.com/kubeflow/pipelines/blob/286a49547cce763c502592c822296aa60f50b3e8/components/google-cloud/tests/types/artifact_types_test.py#L22
For example,
from google_cloud_pipeline_components.types import artifact_types
model = artifact_types.VertexModel(uri='YOUR_MODEL_URI_STRING')
Can you try specifying your model using the syntax above and let us know if this works for your code?
This was a breaking change with release 0.1.9. Here there are some recommendation:
Pin your release to 0.1.7 and continue to use the Model type.
Use 0.1.9 and switch the output from Output[Model] to Output[Artifact].
Try 0.2.0 release, documentation here.
Hope these suggestions work!

Witir browser.link(id: 'identifier').wait_until_present 6.17.0 Usage Issue

The Watir gem has updated one of their browser methods, wait_until_present and it's confusing me.
https://www.rubydoc.info/gems/watir/Watir/Waitable#wait_until_present-instance_method
...says that I should use it like this:
browser.link(id: 'identifier').wait_until_present
However I'm getting this error instead:
WARN Watir [DEPRECATION] ["wait_until_present"] Watir::Anchor#wait_until_present is deprecated. Use Watir::Anchor#wait_until(&:present?) instead.
It's also reported at the bottom here however that English is unclear, as is the solution above.
The reported gem similar methods are as follows:
wait_for_enabled
wait_for_exists
wait_for_present
wait_for_writable
wait_until
wait_until_present
wait_while
wait_while_present
So I don't know which one to use, before the fact I can't get it to work.
Questions:
Which one should I use?
How is it properly used? There's a link on a form that I need to click before a field is viewable.
What does this mean: Use Watir::Anchor#wait_until(&:present?)
Cheers
Found it in other documentation:
browser.text_field(name: "new_user_first_name").wait_until(&:present?).click

On Substrate ink! How can I get Debug information?

I want to get Debug Information.
I implemented this code,but I can not get.
Please tell me how can I get Debug Infomation.
#[ink(message)]
fn set_test_data(&mut self, value: String) {
ink_core::env::println(value);
self.test_data.set(value);
}
Those error messages are printed to the console. Please note that you need to supply the following command line arguments to your node in order to make this happen:
--dev: Use the dev chain spec. You should already be using that.
-lruntime=debug: Increase the log level for runtime generated messages.
It's now in the ink_env crate:
ink_env::debug_println!("{}", "Hello log");
The FAQ entry on this is here:
https://paritytech.github.io/ink-docs/faq/#how-do-i-print-something-to-the-console-from-the-runtime

How to write throws(in java) like code in golang

Is there any way in Golang for a func to "throws"(like in java) an error?
Through Which I can specify , my func may return error and caller needs to handle the error.
I am just trying to mimic "throws" like approach which we have in java.
May be this is very basic elementary type question , sorry for that , I am new in golang.
Note : I have tried panic, defer, recover , but problem is that if both the functions/methods is in same go file it is working properly , but if suppose both(caller and func) are different go file it is starting a different go routine , "defer" at caller level is not working properly.
I guess this approach is not also equivalent like "throws" , where function provider is not handling the error but caller did that , and take the recovery action. Function body provider just specify it may return some exception and caller have to handle the exception.
Thanks in advance...
No, you cannot do that. Go does not support throwing exceptions.
As you have noticed, you can panic and recover, but it's not the same thing.

Dynamic Path is not working in require react native

Below is the code
require("index/components/" + name); //fails
require("index/components/myComponent"); //work fine
any good solution ?
Dynamic paths in require are not currently supported.
Please check this answer
This is covered in the documentation under the section "Static Resources":
The only allowed way to refer to an image in the bundle is to literally write require('name-of-the-asset') in the source.
You can use a switch statement to implement this.
I'm not sure about it but you can try to write it in ES6
require(`index/components/${name}`);

Resources