Blog
Notes On Testing Golang Applications
Setup Main
setup_test.go is where you do any app setup for your test. This runs
before the rest of the tests and can help you mock things that need to be
mocked. When you build your application, test files are ignored. It is a
safe space to declare variables, override variables, etc. Each package can
have a TestMain func in the setup_test.go file.
// setup_test.go in the main package
package main
// may need to declare some testing specific vars up here
var mock *config.AppConfig
var mockDB *sqlDB
func TestMain(m *testing.M) {
// configure your testing specific app config mocks
mockApp.Title = ""
mockApp.DSN = ""
// mock session, repos, pass around any extra config to internal
packages
newSessionManager(mockApp, mockDB)
handlers.SetHandlerRepo(handlers.NewHandlerRepo(mockApp, sqldbconn.NewSQLDbConn(mockApp, mockDB)))
render.NewRenderer(mockApp)
// the rest of the config setup that runs before test
// init TestMain
os.Exit(m.Run())
}
Adding Context And Session To http.Request
Create a couple of helper functions to create dummy session data and add it to the request:
Custom Golang Http Router With Middleware
Go standard library, as well as many others have already solved implementing a robust, production grade http server. So why bother writing one? This post will hopefully yield some insight of why it is important to revisit established technology.
WordPress Self Hosted A Guided Tour To Running Wordpress Independent Of Big Hosting
Learning how to self host a WordPress site can teach us about linux security, web applications technologies, and save us a few dollars. But is it worth it?
Neovim Custom File Extension Syntax Highlighting
We learn how to use treesitter injections to setup syntax highlighting for custom file extensions
Importing Content From Hugo Into Wordpress
I walk through my philosophy on migrating Hugo data sources into wordpress as custom post types.
Why I Dont Recommend Getflywheel or Wpengine for Most Wordpress Hosting
I explain my experience working for an agency that uses GetFlywheel and WPEngine for Wordpress Hosting
Javascript Count Up to Number
This article explores the classic UI component that is the simple count up timer written in Javascript. Often used to help display statistics in a dynamic way.
Golang Send Multipart Form Data to Api Endpoint
We often need to send data and files from one JSON API endpoint to another. In this post, I explain how to use multipartform writer to send form data across api endpoint boundaries.
Create an Accessible Vanilla Javascript Accordion
The accordion is a user interface component that helps structure and display website information through an expansion/contraction mechanism. This article explores building a vanilla javascript accordion with accessibility in mind.
Setup DisplayLink on Manjaro Linux
Getting displaylink drivers to work on Arch linux flavors can be challenging to newcomers. Here are my notes for getting displaylink drivers working on Manjaro Linux.