-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproblem_config_test.go
More file actions
40 lines (31 loc) · 961 Bytes
/
problem_config_test.go
File metadata and controls
40 lines (31 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package httpsuite
import "testing"
func TestProblemConfigTypeURL(t *testing.T) {
t.Parallel()
config := ProblemConfig{
BaseURL: "https://api.example.com/",
ErrorTypePaths: map[string]string{
"validation_error": "errors/validation-error",
},
}
got := config.TypeURL("validation_error")
want := "https://api.example.com/errors/validation-error"
if got != want {
t.Fatalf("expected %q, got %q", want, got)
}
}
func TestProblemConfigTypeURLUnknown(t *testing.T) {
t.Parallel()
config := NewProblemConfig()
if got := config.TypeURL("missing"); got != BlankURL {
t.Fatalf("expected %q, got %q", BlankURL, got)
}
}
func TestDefaultProblemConfigReturnsCopy(t *testing.T) {
t.Parallel()
config := DefaultProblemConfig()
config.ErrorTypePaths["validation_error"] = "/custom"
if got := GetProblemTypeURL("validation_error"); got != "/errors/validation-error" {
t.Fatalf("expected default config to stay unchanged, got %q", got)
}
}