MCPcopy Index your code
hub / github.com/google/go-github / TestNewRequest_errorForNoTrailingSlash

Function TestNewRequest_errorForNoTrailingSlash

github/github_test.go:1657–1679  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1655}
1656
1657func TestNewRequest_errorForNoTrailingSlash(t *testing.T) {
1658 t.Parallel()
1659 tests := []struct {
1660 rawurl string
1661 wantError bool
1662 }{
1663 {rawurl: "https://example.com/api/v3", wantError: true},
1664 {rawurl: "https://example.com/api/v3/", wantError: false},
1665 }
1666 c := mustNewClient(t)
1667 for _, test := range tests {
1668 u, err := url.Parse(test.rawurl)
1669 if err != nil {
1670 t.Fatalf("url.Parse returned unexpected error: %v.", err)
1671 }
1672 c.baseURL = u
1673 if _, err := c.NewRequest(t.Context(), "GET", "test", nil); test.wantError && err == nil {
1674 t.Fatal("Expected error to be returned.")
1675 } else if !test.wantError && err != nil {
1676 t.Fatalf("NewRequest returned unexpected error: %v.", err)
1677 }
1678 }
1679}
1680
1681func TestCheckURLPathTraversal(t *testing.T) {
1682 t.Parallel()

Callers

nothing calls this directly

Calls 2

mustNewClientFunction · 0.85
NewRequestMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…