Skip to content

Show curl command when error format option is set to long #4101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ashishajr
Copy link
Contributor

Description

  • Show curl command when hurl is run with --error-format long

Issue

#2226

Discussion

Hey @jcamiel, I had a couple of questions

  1. I didn't know where exactly to place the code for this so right now I've just put it before the response info is logged, let me know if I need ot move it to a better place for readbility
  2. In your comment you have mentioned the log to be similar to how it's in debug
$ hurl --error-format long --test test.hurl
* Request can be run with the following curl command:
* curl 'http://localhost:8000/not-found'

HTTP/1.1 200
Connection: close
Date: Tue, 05 Dec 2023 12:22:54 GMT
Referer-Policy: strict-origin-when-cross-origin
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 0
Request-Mapping: /api/mobile/orders/orderid/contractualdocuments
Container-Id:
Cache-Control: no-store, must-revalidate
Content-Type: application/json;charset=utf-8
Server: Jetty(9.4.49.v20220914)
Transfer-Encoding: chunked

{"documents":[{"id":"orange-et-vous_cg_3187.pdf","label":"Conditions générales de vente de la boutique en ligne","link":"https://documentscontractuels.orange.fr/orange-et-vous_cg_3187.pdf"},{"id":"les-offres-orange-mobile_cg_929.pdf","label":"Conditions générales d'abonnement et spécifiques de l'offre mobile Orange","link":"https://documentscontractuels.orange.fr/les-offres-orange-mobile_cg_929.pdf"},{"id":"les-offres-orange-mobile_fit_3788.pdf","label":"Les Tarifs des Offres Mobile et Packs Open","link":"https://documentscontractuels.orange.fr/les-offres-orange-mobile_fit_3788.pdf"},{"id":"les-offres-orange-mobile_ann_2899.pdf","label":"Formulaire de rétractation Orange","link":"https://documentscontractuels.orange.fr/les-offres-orange-mobile_ann_2899.pdf"},{"id":"les-offres-orange-mobile_cs_3551.pdf","label":"Conditions spécifiques Changement de Mobile","link":"https://documentscontractuels.orange.fr/les-offres-orange-mobile_cs_3551.pdf"},{"id":"les-offres-orange-mobile_rc_4625.pdf","label":"Forfait 200 Go 5G","link":"https://documentscontractuels.orange.fr/les-offres-orange-mobile_rc_4625.pdf"}],"conditions":["Je reconnais avoir pris connaissance des documents et accepte les conditions contractuelles.","Je souhaite bénéficier de mon service dès qu'il pourra être activé par Orange. Si cette activation intervient avant la fin du délai de rétractation de 21 jours et que je change d'avis et me rétracte, Orange pourra me facturer l'utilisation que j'aurai faite du service pendant ce délai."]}

error: Assert failure
  --> integration/tests/orange-mobile-pcmoa/hurl/tunnel-complet-pcmoa-mobile.hurl:216:0
   |
216 | jsonpath "$.documents[5].link" == "https://documentscontractuels.orange.fr/les-offres-orange-mobile_rc_4625.pd"
   |   actual:   string <https://documentscontractuels.orange.fr/les-offres-orange-mobile_rc_4625.pdf>
   |   expected: string <https://documentscontractuels.orange.fr/les-offres-orange-mobile_rc_4625.pd>
   |

integration/tests/orange-mobile-pcmoa/hurl/tunnel-complet-pcmoa-mobile.hurl: Failure (16 request(s) in 54783 ms)
--------------------------------------------------------------------------------
Executed files:  1
Succeeded files: 0 (0.0%)
Failed files:    1 (100.0%)
Duration:        54788 ms

In code I see that to ge the * before I need to use the debug or debug_important function but that is available only when the verbosity is not None

/// Prints a given message to this logger [`Stderr`] instance, no matter what is the verbosity.
pub fn info(&mut self, message: &str) {
self.eprintln(message);
}
/// Prints a given debug message to this logger [`Stderr`] instance, in verbose and very verbose mode.
///
/// Displayed debug messages start with `*`.
pub fn debug(&mut self, message: &str) {
if self.verbosity.is_none() {
return;
}
let fmt = self.format();
let mut s = StyledString::new();
s.push_with("*", Style::new().blue().bold());
if !message.is_empty() {
s.push(" ");
s.push(message);
}
self.eprintln(&s.to_string(fmt));
}
/// Prints a given debug message in bold to this logger [`Stderr`] instance, in verbose and very verbose mode.
///
/// Displayed debug messages start with `*`.
pub fn debug_important(&mut self, message: &str) {
if self.verbosity.is_none() {
return;
}
let fmt = self.format();
let mut s = StyledString::new();
s.push_with("*", Style::new().blue().bold());
if !message.is_empty() {
s.push(" ");
s.push_with(message, Style::new().bold());
}
self.eprintln(&s.to_string(fmt));
}

Should I create a new info_important function to add * before the log no matter the verbosity or do you want me to just add a * in the message? What would you suggest I do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants