mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Use subtests with server_test.go
Use Golang's subtests to provide a convenient way to run specific tests. Example: go test -run=TestFixURL/Basic_production
This commit is contained in:
parent
ce8a09a4c0
commit
843fcd19d4
1 changed files with 17 additions and 15 deletions
|
@ -97,7 +97,8 @@ func TestFixURL(t *testing.T) {
|
|||
{"No config", "", "", true, 1313, "//localhost:1313/"},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
for _, test := range tests {
|
||||
t.Run(test.TestName, func(t *testing.T) {
|
||||
b := newCommandsBuilder()
|
||||
s := b.newServerCmd()
|
||||
v := viper.New()
|
||||
|
@ -107,11 +108,12 @@ func TestFixURL(t *testing.T) {
|
|||
s.serverPort = test.Port
|
||||
result, err := s.fixURL(v, baseURL, s.serverPort)
|
||||
if err != nil {
|
||||
t.Errorf("Test #%d %s: unexpected error %s", i, test.TestName, err)
|
||||
t.Errorf("Unexpected error %s", err)
|
||||
}
|
||||
if result != test.Result {
|
||||
t.Errorf("Test #%d %s: expected %q, got %q", i, test.TestName, test.Result, result)
|
||||
t.Errorf("Expected %q, got %q", test.Result, result)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue