This file contains hidden or 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
package main | |
import ( | |
"context" | |
"database/sql" | |
"log" | |
"net/http" | |
"os" | |
"time" |
This file contains hidden or 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
package purchaseshistory | |
import ( | |
"github.com/go-chi/chi" | |
"go.uber.org/fx" | |
) | |
var Module = fx.Options( | |
fx.Invoke(registerEndpoints), | |
factories, |
This file contains hidden or 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
// +build integration | |
package purchaseshistory | |
import ( | |
"context" | |
"database/sql" | |
"testing" | |
"github.com/stretchr/testify/assert" |
This file contains hidden or 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
func TestPurchase_success(t *testing.T) { | |
input := `{ | |
"user_id": 1, | |
"books": [ | |
{ | |
"id": 1, | |
"quantity": 2, | |
"price": 19.9 | |
} | |
] |
This file contains hidden or 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
type HelloHandler struct { | |
} | |
func NewHelloHandler() HelloHandler { | |
return HelloHandler{} | |
} | |
func (h HelloHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
_, _ = fmt.Fprintf(w, "Hello") | |
} |
This file contains hidden or 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
type ( | |
PurchasePersister interface { | |
Persist(context.Context, purchases.Purchase) error | |
} | |
PurchaseHandler struct { | |
persister PurchasePersister | |
} | |
) |
This file contains hidden or 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
package main | |
import ( | |
"bytes" | |
"fmt" | |
"strings" | |
"github.com/diegoholiveira/jsonlogic" | |
) |
This file contains hidden or 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
#!/usr/bin/env bash | |
# source: https://dev.to/thiht/shell-scripts-matter | |
set -euo pipefail | |
IFS=$'\n\t' | |
readonly LOG_FILE="/tmp/$(basename "$0").log" | |
info() { echo "[INFO] $*" | tee -a "$LOG_FILE" >&2 ; } | |
warning() { echo "[WARNING] $*" | tee -a "$LOG_FILE" >&2 ; } | |
error() { echo "[ERROR] $*" | tee -a "$LOG_FILE" >&2 ; } | |
fatal() { echo "[FATAL] $*" | tee -a "$LOG_FILE" >&2 ; exit 1 ; } |