mirror of
https://github.com/aykhans/sarin.git
synced 2026-02-28 14:59:14 +00:00
Add e2e tests
This commit is contained in:
61
e2e/show_config_test.go
Normal file
61
e2e/show_config_test.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestShowConfigNonTTY(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// In non-TTY mode (like tests), -s should output raw YAML and exit
|
||||
res := run("-U", "http://example.com", "-r", "1", "-s")
|
||||
assertExitCode(t, res, 0)
|
||||
|
||||
// Should contain YAML-formatted config
|
||||
assertContains(t, res.Stdout, "url:")
|
||||
assertContains(t, res.Stdout, "example.com")
|
||||
assertContains(t, res.Stdout, "requests:")
|
||||
}
|
||||
|
||||
func TestShowConfigContainsMethod(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
res := run("-U", "http://example.com", "-r", "1", "-M", "POST", "-s")
|
||||
assertExitCode(t, res, 0)
|
||||
|
||||
assertContains(t, res.Stdout, "method:")
|
||||
assertContains(t, res.Stdout, "POST")
|
||||
}
|
||||
|
||||
func TestShowConfigContainsHeaders(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
res := run("-U", "http://example.com", "-r", "1", "-s",
|
||||
"-H", "X-Custom: test-value")
|
||||
assertExitCode(t, res, 0)
|
||||
|
||||
assertContains(t, res.Stdout, "X-Custom")
|
||||
assertContains(t, res.Stdout, "test-value")
|
||||
}
|
||||
|
||||
func TestShowConfigContainsTimeout(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
res := run("-U", "http://example.com", "-r", "1", "-T", "5s", "-s")
|
||||
assertExitCode(t, res, 0)
|
||||
|
||||
assertContains(t, res.Stdout, "timeout:")
|
||||
}
|
||||
|
||||
func TestShowConfigWithEnvVars(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
res := runWithEnv(map[string]string{
|
||||
"SARIN_URL": "http://example.com",
|
||||
"SARIN_REQUESTS": "5",
|
||||
}, "-s")
|
||||
assertExitCode(t, res, 0)
|
||||
|
||||
assertContains(t, res.Stdout, "example.com")
|
||||
assertContains(t, res.Stdout, "requests:")
|
||||
}
|
||||
Reference in New Issue
Block a user