Skip to content

Instantly share code, notes, and snippets.

View mr-pascal's full-sized avatar

Pascal mr-pascal

View GitHub Profile
export FIRESTORE_EMULATOR_HOST=localhost:8090 && go run .
package main
import (
"context"
"log"
"os"
"cloud.google.com/go/firestore"
)
module main
go 1.16
require cloud.google.com/go/firestore v1.5.0
go test -v . | sed ''/PASS/s//$(printf "\033[32mPASS\033[0m")/'' | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/''
package main
import (
"bytes"
"encoding/json"
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
//.....
const sumMethodName = "Sum"
const multiplyMethodName = "Multiply"
type AppHandlerFake struct {
// method name -> call -> params
Calls map[string][][]interface{}
}
package main
type Result struct {
Value int `json:"value"`
}
type AppHandler interface {
Sum(x, y int) Result
Multiply(x, y int) Result
}
package main
import (
"log"
"strconv"
"github.com/gofiber/fiber/v2"
)
// Request body payload of the 'POST /multiply' endpoint
package main
import (
"testing"
)
func TestMultiply(t *testing.T) {
// Create the test table
tables := []struct {
package main
func Multiply(x, y int) int {
return x * y
}