forked from mtusi2026/mtusi2026lab2
test: add resilience and benchmark verification
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRunRequiresAddress(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
host string
|
||||
port string
|
||||
want string
|
||||
}{
|
||||
{name: "missing host", port: "8080", want: "APP_HOST is required"},
|
||||
{name: "missing port", host: "127.0.0.1", want: "APP_PORT is required"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Setenv("APP_HOST", tt.host)
|
||||
t.Setenv("APP_PORT", tt.port)
|
||||
if err := run(nil); err == nil || !strings.Contains(err.Error(), tt.want) {
|
||||
t.Fatalf("run() error = %v, want %q", err, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user