Skip to content

Instantly share code, notes, and snippets.

View dickyaryag6's full-sized avatar

Dicky arya Kesuma dickyaryag6

  • Jakarta Metropolitan Area
  • 14:35 (UTC +07:00)
View GitHub Profile
// Code generated by MockGen. DO NOT EDIT.
// Source: gomocking/repository (interfaces: DatabaseInterface)
// Package mocks is a generated GoMock package.
package mocks
import (
gomock "github.com/golang/mock/gomock"
reflect "reflect"
)
package repository
import (
"fmt"
)
type Database struct {}
func New(db Database) Database {
return db
package repository
type DatabaseInterface interface {
Insert(number int) error
}
package usecase
import (
"errors"
"gomocking/mocks"
"gomocking/repository"
"testing"
"github.com/golang/mock/gomock"
"github.com/undefinedlabs/go-mpatch"
package usecase
import (
"errors"
"gomocking/repository"
"strconv"
)
type Usecase struct {
Database repository.DatabaseInterface
package main
import (
"fmt"
uc "gomocking/usecase"
db "gomocking/database"
)
func main() {
INSERT INTO person
(name, country, job, age)
values ('Mike', 'England', 'Software Engineer', 30)
ON CONFLICT ON CONSTRAINT person_name_country_unique
DO NOTHING;
ALTER TABLE person
ADD CONSTRAINT person_name_country_unique UNIQUE ("name", country);
INSERT INTO person
(name, country, job, age)
values ('Mike', 'England', 'Software Engineer', 5)
ON CONFLICT (name)
DO UPDATE SET age = person.age + EXCLUDED.age;
INSERT INTO person
(name, country, job, age)
values ('Peter', 'Egypt', 'Engineering Manager', 32)
ON CONFLICT (name)
DO UPDATE SET job = EXCLUDED.job || ',' || person.job;