Skip to content

Instantly share code, notes, and snippets.

View Pyrolistical's full-sized avatar

Pyrolistical

View GitHub Profile
@Pyrolistical
Pyrolistical / pyluxcore.pyi
Created April 19, 2023 22:46
mypy stubgen output of pyluxcore.pyd 2.6
from typing import Any, ClassVar
import Boost.Python
class Camera(Boost.Python.instance):
@classmethod
def __init__(cls, *args, **kwargs) -> None: ...
@classmethod
def Rotate(cls, *args, **kwargs) -> Any: ...
@classmethod
@Pyrolistical
Pyrolistical / repository.js
Created October 22, 2021 23:47
ecommerce-escalation v2 repo
export default (mongoClient, db) => {
return {
async checkoutTransaction(closure) {
const session = mongoClient.startSession({
causalConsistency: true
});
try {
const sessionRepository = {
async findInventoryByProuctSkus(productSkus) {
return db.collection('inventory').find({
@Pyrolistical
Pyrolistical / service.spec.js
Created October 22, 2021 23:46
ecommerce-escalation v2 test
import {jest} from '@jest/globals';
import Service, {InsufficientStock} from './service';
describe('checkout', () => {
test('fails when insufficient stock for desired product', async () => {
const session = {
findInventoryByProuctSkus: jest.fn()
.mockResolvedValueOnce([
{
@Pyrolistical
Pyrolistical / service.spec.js
Created October 22, 2021 23:03
ecommerce-escalation v1 test
import {jest} from '@jest/globals';
import Service, {InsufficientStock} from './service';
describe('checkout', () => {
test('fails when insufficient stock for desired product', async () => {
const repository = {
findInventoryByProductSku: jest.fn()
.mockResolvedValueOnce({
productSku: 'some product sku',
@Pyrolistical
Pyrolistical / service.js
Created October 22, 2021 07:43
ecommerce-escalation v2
import _ from 'lodash';
export class InsufficientStock extends Error {
constructor(message) {
super(message);
this.name = 'InsufficientStock';
}
}
export default (repository) => {
@Pyrolistical
Pyrolistical / service.js
Created October 22, 2021 07:42
ecommerce-escalation v1
import _ from 'lodash';
export class InsufficientStock extends Error {
constructor(message) {
super(message);
this.name = 'InsufficientStock';
}
}
export default (repository) => {
@Pyrolistical
Pyrolistical / repository.js
Created October 10, 2021 05:59
separate business layer from infrastructure layer after alternative checkInTeam
async checkInTeam(teamID) {
return db.collection('teams').updateOne({
_id: teamID
}, {
$set: {
checkedInAt: new Date()
}
});
}
@Pyrolistical
Pyrolistical / service.spec.js
Last active October 9, 2021 22:25
separate business layer from infrastructure layer after test
import {jest} from '@jest/globals'
import Service from './service';
test('teams with disqualified players cannot check-in', async () => {
const repository = {
findDisqualifiedPlayers: jest.fn()
.mockResolvedValueOnce([
{
teamID: 'some team id',
@Pyrolistical
Pyrolistical / service.spec.js
Created October 9, 2021 21:36
separate business layer from infrastructure layer before service.spec.js with jest mocks
import {jest} from '@jest/globals'
import Service from './service';
test('teams with disqualified players cannot check-in', async () => {
const playerDisqualificationsFindToArray = jest.fn()
.mockResolvedValueOnce([
{
teamID: 'some team id',
reason: 'was a big meanie'
@Pyrolistical
Pyrolistical / service.spec.js
Created October 9, 2021 21:17
separate business layer from infrastructure layer before service.spec.js
import Service from './service';
test('teams with disqualified players cannot check-in', async () => {
const db = {
collection(collection) {
switch (collection) {
case 'playerDisqualifications': {
return {
find({teamID}) {
expect(teamID).toBe('some team id');