3 Commits

Author SHA1 Message Date
d197e90103 Merge pull request #172 from aykhans/refactor/minor-improvements
Rename Append to Merge, replace strings_Join with slice_Join, and auto-detect non-TTY output
2026-02-15 16:55:40 +04:00
ae054bb3d6 update docs 2026-02-15 16:52:52 +04:00
61af28a3d3 Override Methods and Bodies instead of appending in Config.Merge 2026-02-15 16:27:36 +04:00
4 changed files with 38 additions and 32 deletions

View File

@@ -105,6 +105,12 @@ SARIN_CONFIG_FILE=/config1.yaml sarin -f /config2.yaml -f https://example.com/co
If all four files define `url`, the value from `config3.yaml` wins. If all four files define `url`, the value from `config3.yaml` wins.
**Merge behavior by field:**
- **Scalar fields** (`url`, `requests`, `duration`, `timeout`, `concurrency`, etc.) — higher priority overrides lower priority
- **Method and Body** — higher priority overrides lower priority (no merging)
- **Headers, Params, Cookies, Proxies, Values, Lua, and Js** — accumulated across all config files
## URL ## URL
Target URL. Must be HTTP or HTTPS. The URL path supports [templating](templating.md), allowing dynamic path generation per request. Target URL. Must be HTTP or HTTPS. The URL path supports [templating](templating.md), allowing dynamic path generation per request.

View File

@@ -199,7 +199,7 @@ params:
```sh ```sh
sarin -U http://example.com/users -r 1000 -c 10 \ sarin -U http://example.com/users -r 1000 -c 10 \
-P "id={{ fakeit_IntRange 1 1000 }}" \ -P "id={{ fakeit_Number 1 1000 }}" \
-P "fields=name,email" -P "fields=name,email"
``` ```
@@ -211,7 +211,7 @@ url: http://example.com/users
requests: 1000 requests: 1000
concurrency: 10 concurrency: 10
params: params:
id: "{{ fakeit_IntRange 1 1000 }}" id: "{{ fakeit_Number 1 1000 }}"
fields: "name,email" fields: "name,email"
``` ```

View File

@@ -240,7 +240,7 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
### Address ### Address
| Function | Description | Example Output | | Function | Description | Example Output |
| --------------------------------------------------- | ---------------------------- | --------------------------------------------------- | | --------------------------------------------------- | ---------------------------- | ---------------------------------------------------- |
| `fakeit_City` | City name | `"Marcelside"` | | `fakeit_City` | City name | `"Marcelside"` |
| `fakeit_Country` | Country name | `"United States of America"` | | `fakeit_Country` | Country name | `"United States of America"` |
| `fakeit_CountryAbr` | Country abbreviation | `"US"` | | `fakeit_CountryAbr` | Country abbreviation | `"US"` |
@@ -256,7 +256,7 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
| `fakeit_Latitude` | Random latitude | `-73.534056` | | `fakeit_Latitude` | Random latitude | `-73.534056` |
| `fakeit_Longitude` | Random longitude | `-147.068112` | | `fakeit_Longitude` | Random longitude | `-147.068112` |
| `fakeit_LatitudeInRange(min float64, max float64)` | Latitude in specified range | `{{ fakeit_LatitudeInRange 0 90 }}``22.921026` | | `fakeit_LatitudeInRange(min float64, max float64)` | Latitude in specified range | `{{ fakeit_LatitudeInRange 0 90 }}``22.921026` |
| `fakeit_LongitudeInRange(min float64, max float64)` | Longitude in specified range | `{{ fakeit_LongitudeInRange 0 180 }}``-8.170450` | | `fakeit_LongitudeInRange(min float64, max float64)` | Longitude in specified range | `{{ fakeit_LongitudeInRange 0 180 }}``122.471830` |
### Game ### Game
@@ -344,8 +344,8 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
### Text ### Text
| Function | Description | Example | | Function | Description | Example |
| ---------------------------------------------------------------------------------------- | ----------------------------------------------- | --------------------------------------------- | | ---------------------------------------------------------------------------------------- | ----------------------------------------------- | ----------------------------------------------------- |
| `fakeit_Sentence` | Random sentence | `{{ fakeit_Sentence }}` | | `fakeit_Sentence(wordCount ...int)` | Random sentence (optional word count) | `{{ fakeit_Sentence }}` or `{{ fakeit_Sentence 10 }}` |
| `fakeit_Paragraph` | Random paragraph | `{{ fakeit_Paragraph }}` | | `fakeit_Paragraph` | Random paragraph | `{{ fakeit_Paragraph }}` |
| `fakeit_LoremIpsumWord` | Lorem ipsum word | `"lorem"` | | `fakeit_LoremIpsumWord` | Lorem ipsum word | `"lorem"` |
| `fakeit_LoremIpsumSentence(wordCount int)` | Lorem ipsum sentence with specified word count | `{{ fakeit_LoremIpsumSentence 5 }}` | | `fakeit_LoremIpsumSentence(wordCount int)` | Lorem ipsum sentence with specified word count | `{{ fakeit_LoremIpsumSentence 5 }}` |

View File

@@ -275,7 +275,7 @@ func (config Config) Print() bool {
func (config *Config) Merge(newConfig *Config) { func (config *Config) Merge(newConfig *Config) {
config.Files = append(config.Files, newConfig.Files...) config.Files = append(config.Files, newConfig.Files...)
if len(newConfig.Methods) > 0 { if len(newConfig.Methods) > 0 {
config.Methods = append(config.Methods, newConfig.Methods...) config.Methods = newConfig.Methods
} }
if newConfig.URL != nil { if newConfig.URL != nil {
config.URL = newConfig.URL config.URL = newConfig.URL
@@ -317,7 +317,7 @@ func (config *Config) Merge(newConfig *Config) {
config.Cookies = append(config.Cookies, newConfig.Cookies...) config.Cookies = append(config.Cookies, newConfig.Cookies...)
} }
if len(newConfig.Bodies) != 0 { if len(newConfig.Bodies) != 0 {
config.Bodies = append(config.Bodies, newConfig.Bodies...) config.Bodies = newConfig.Bodies
} }
if len(newConfig.Proxies) != 0 { if len(newConfig.Proxies) != 0 {
config.Proxies.Append(newConfig.Proxies...) config.Proxies.Append(newConfig.Proxies...)