Skip to content

Instantly share code, notes, and snippets.

@AntonStoeckl
Last active February 1, 2022 10:07
Show Gist options
  • Save AntonStoeckl/77f127eb0d88a30bc9d349623a43677f to your computer and use it in GitHub Desktop.
Save AntonStoeckl/77f127eb0d88a30bc9d349623a43677f to your computer and use it in GitHub Desktop.
Example for blog post: Go bits: Magic with functions
package functionsandinterfaces_test
import (
"testing"
"github.com/matryer/is"
. "go-bits/magic-with-functions/functionsandinterfaces"
)
func Test_isBigger_with_a_closure(t *testing.T) {
// Arrange
shouldBe := is.New(t)
realFunction := RegisterCustomer
castedFunction := ForRegisteringCustomersFunc(realFunction)
handler := NewCustomerRegistrationHTTPHandler(castedFunction)
// Act
err := handler.Handle("John Doe", "[email protected]")
// Assert
shouldBe.NoErr(err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment