Skip to content

Commit

Permalink
addressing lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ac4ch committed May 17, 2024
1 parent d2471de commit 7f1c206
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 1 addition & 2 deletions access_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import (
"net/http/httptest"
"testing"

"github.com/bitcoin-sv/spv-wallet-go-client/fixtures"
"github.com/bitcoin-sv/spv-wallet/models"
"github.com/stretchr/testify/require"

"github.com/bitcoin-sv/spv-wallet-go-client/fixtures"
)

// TestAccessKeys will test the AccessKey methods
Expand Down
15 changes: 10 additions & 5 deletions transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import (
"net/http/httptest"
"testing"

"github.com/bitcoin-sv/spv-wallet-go-client/fixtures"
"github.com/bitcoin-sv/spv-wallet/models"
"github.com/stretchr/testify/require"

"github.com/bitcoin-sv/spv-wallet-go-client/fixtures"
)

func TestTransactions(t *testing.T) {
Expand Down Expand Up @@ -87,12 +86,16 @@ func TestTransactions(t *testing.T) {
func handleTransaction(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet, http.MethodPost:
json.NewEncoder(w).Encode(fixtures.Transaction)
if err := json.NewEncoder(w).Encode(fixtures.Transaction); err != nil {
http.Error(w, "Failed to encode response", http.StatusInternalServerError)
}
case http.MethodPatch:
var input map[string]interface{}
if err := json.NewDecoder(r.Body).Decode(&input); err != nil {
w.WriteHeader(http.StatusBadRequest)
json.NewEncoder(w).Encode(map[string]string{"error": "bad request"})
if err := json.NewEncoder(w).Encode(map[string]string{"error": "bad request"}); err != nil {
http.Error(w, "Failed to encode error response", http.StatusInternalServerError)
}
return
}
response := fixtures.Transaction
Expand All @@ -103,7 +106,9 @@ func handleTransaction(w http.ResponseWriter, r *http.Request) {
response.ID = id
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(response)
if err := json.NewEncoder(w).Encode(response); err != nil {
http.Error(w, "Failed to encode response", http.StatusInternalServerError)
}
default:
w.WriteHeader(http.StatusMethodNotAllowed)
}
Expand Down

0 comments on commit 7f1c206

Please sign in to comment.