-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: ccoVeille <[email protected]>
- Loading branch information
Showing
13 changed files
with
485 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
analyzer/testdata/src/checkers-default/http-const/http_const_test.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
analyzer/testdata/src/checkers-default/http-const/http_const_test.go.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Code generated by testifylint/internal/testgen. DO NOT EDIT. | ||
package httpconst | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"net/url" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func httpOK(w http.ResponseWriter, r *http.Request) { | ||
w.WriteHeader(http.StatusOK) | ||
} | ||
|
||
func httpHelloName(w http.ResponseWriter, r *http.Request) { | ||
name := r.FormValue("name") | ||
_, _ = fmt.Fprintf(w, "Hello, %s!", name) | ||
} | ||
|
||
func TestHttpConstChecker(t *testing.T) { | ||
// Invalid. | ||
{ | ||
assert.HTTPStatusCode(t, httpOK, http.MethodGet, "/index", nil, http.StatusOK) // want "http-const: use net/http constants instead of value" | ||
assert.HTTPStatusCodef(t, httpOK, http.MethodGet, "/index", nil, http.StatusOK, "msg with args %d %s", 42, "42") // want "http-const: use net/http constants instead of value" | ||
assert.HTTPStatusCode(t, httpOK, http.MethodGet, "/index", nil, http.StatusOK) // want "http-const: use net/http constants instead of value" | ||
assert.HTTPStatusCodef(t, httpOK, http.MethodGet, "/index", nil, http.StatusOK, "msg with args %d %s", 42, "42") // want "http-const: use net/http constants instead of value" | ||
assert.HTTPStatusCode(t, httpOK, http.MethodGet, "/index", nil, http.StatusOK) // want "http-const: use net/http constants instead of value" | ||
assert.HTTPStatusCodef(t, httpOK, http.MethodGet, "/index", nil, http.StatusOK, "msg with args %d %s", 42, "42") // want "http-const: use net/http constants instead of value" | ||
assert.HTTPBodyContains(t, httpHelloName, http.MethodGet, "/", url.Values{"name": []string{"World"}}, "Hello, World!") // want "http-const: use net/http constants instead of value" | ||
assert.HTTPBodyContainsf(t, httpHelloName, http.MethodGet, "/", url.Values{"name": []string{"World"}}, "Hello, World!", "msg with args %d %s", 42, "42") // want "http-const: use net/http constants instead of value" | ||
} | ||
// Valid. | ||
{ | ||
assert.HTTPStatusCode(t, httpOK, http.MethodGet, "/index", nil, http.StatusOK) | ||
assert.HTTPStatusCodef(t, httpOK, http.MethodGet, "/index", nil, http.StatusOK, "msg with args %d %s", 42, "42") | ||
assert.HTTPBodyContains(t, httpHelloName, http.MethodGet, "/", url.Values{"name": []string{"World"}}, "Hello, World!") | ||
assert.HTTPBodyContainsf(t, httpHelloName, http.MethodGet, "/", url.Values{"name": []string{"World"}}, "Hello, World!", "msg with args %d %s", 42, "42") | ||
} | ||
// Ignored. | ||
{ | ||
assert.HTTPStatusCode(t, httpOK, "FOO", "/index", nil, 999) | ||
assert.HTTPStatusCodef(t, httpOK, "FOO", "/index", nil, 999, "msg with args %d %s", 42, "42") | ||
assert.HTTPBodyContains(t, httpHelloName, "FOO", "/", url.Values{"name": []string{"World"}}, "Hello, World!") | ||
assert.HTTPBodyContainsf(t, httpHelloName, "FOO", "/", url.Values{"name": []string{"World"}}, "Hello, World!", "msg with args %d %s", 42, "42") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.