Skip to content

Commit

Permalink
Fix lint errors in test, re-generate example versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmars committed Jan 14, 2022
1 parent 590ea80 commit 1963fca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ lint-docker:
.PHONY: test
test:
go test ./... -count=1
(cd versionware/example; go test ./... -count=1)
(cd versionware/example; go generate . && go test ./... -count=1)

.PHONY: test-coverage
test-coverage:
Expand Down
21 changes: 16 additions & 5 deletions versionware/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ type validatorTestHandler struct {
errStatusCode int
}

const v20210820_Body = `{"id": "42", "contents": {"name": "foo", "expected": 9, "actual": 10}}`
const v20210916_Body = `{"id": "42", "contents": {"name": "foo", "expected": 9, "actual": 10, "noodles": true}}`

func (h validatorTestHandler) withDefaults() validatorTestHandler {
Expand All @@ -216,21 +215,33 @@ func (h *validatorTestHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
w.Header().Set("Content-Type", h.contentType)
if h.errStatusCode != 0 {
w.WriteHeader(h.errStatusCode)
w.Write([]byte(h.errBody))
_, err := w.Write([]byte(h.errBody))
if err != nil {
panic(err)
}
return
}
if !testUrlRE.MatchString(r.URL.Path) {
w.WriteHeader(http.StatusNotFound)
w.Write([]byte(h.errBody))
_, err := w.Write([]byte(h.errBody))
if err != nil {
panic(err)
}
return
}
switch r.Method {
case "GET":
w.WriteHeader(http.StatusOK)
w.Write([]byte(h.getBody))
_, err := w.Write([]byte(h.getBody))
if err != nil {
panic(err)
}
case "POST":
w.WriteHeader(http.StatusCreated)
w.Write([]byte(h.postBody))
_, err := w.Write([]byte(h.postBody))
if err != nil {
panic(err)
}
default:
http.Error(w, h.errBody, http.StatusMethodNotAllowed)
}
Expand Down

0 comments on commit 1963fca

Please sign in to comment.