Skip to content

Instantly share code, notes, and snippets.

View utkarshmani1997's full-sized avatar
🎯
Focusing

Utkarsh Mani Tripathi utkarshmani1997

🎯
Focusing
View GitHub Profile
package database
//go:generate mockgen -destination=mocks/mock_users.go -package=mocks github.com/utkarshmani1997/talks/12Dec2020/techniques/mocking/sample_app/database Users
const (
insertQuery = `
INSERT INTO users (age, email, first_name, last_name)
VALUES ($1, $2, $3, $4)
RETURNING id
`
func TestInsertUser(t *testing.T) {
mockCtl := gomock.NewController(t)
defer mockCtl.Finish()
mockUser := mock_database.NewMockUsers(mockCtl)
gomock.InOrder(
mockUser.EXPECT().Insert().Return(0, fmt.Errorf("%v", "insert error")).Times(1),
mockUser.EXPECT().Insert().Return(5, nil).Times(1),
)
_, err := insertUser(mockUser)
if err == nil {
package mock_database
import (
reflect "reflect"
gomock "github.com/golang/mock/gomock"
)
// MockUsers is a mock of Users interface
type MockUsers struct {
package main
import "github.com/utkarshmani1997/talks/12Dec2020/techniques/mocking/sample_app/database"
func main() {
database.Setup()
user := database.NewUser(23, "gmail.com", "Utkarsh", "Mani Tripathi")
insertUser(user)
database.TearDown()
}
package database
const (
insertQuery = `
INSERT INTO users (age, email, first_name, last_name)
VALUES ($1, $2, $3, $4)
RETURNING id
`
)
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: openebs-nfs-provisioner-runner
rules:
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "create", "delete"]
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
kind: PodSecurityPolicy
metadata:
name: openebs-nfs-provisioner
spec:
fsGroup:
rule: RunAsAny
allowedCapabilities:
- DAC_READ_SEARCH
- SYS_RESOURCE
runAsUser:
Portal Details :
- - - - - - - -
IQN : iqn.2016–09.com.openebs.jiva:pvc-5b0c7dc4-df68–11e9-b597–005056bda303
Volume : pvc-5b0c7dc4-df68–11e9-b597–005056bda303
Portal : 10.120.10.10:3260
Size : 150Gi
Controller Status : running,running
Controller Node : node-1
Replica Count : 3
Replica Details :
@utkarshmani1997
utkarshmani1997 / map.go
Created June 1, 2019 01:24
Idiomatic vs non-idiomatic
package main
import "fmt"
type myMap map[string]string
func (m myMap) contains(key string) (val string, ok bool) {
val, ok = m[key]
return val, ok
}
@utkarshmani1997
utkarshmani1997 / vm-resize-hard-disk.md
Created November 13, 2018 11:56 — forked from christopher-hopper/vm-resize-hard-disk.md
Resize a Hard Disk for a Virtual Machine provisioned using Vagrant from a Linux base box to run using VirutalBox.

Resize a Hard Disk for a Virtual Machine

Our Virtual Machines are provisioned using Vagrant from a Linux base box to run using VirutalBox. If the Hard Disk space runs out and you cannot remove files to free-up space, you can resize the Hard Disk using some VirtualBox and Linux commands.

Some assumptions

The following steps assume you've got a set-up like mine, where: