Skip to content

Instantly share code, notes, and snippets.

@mrrizal
mrrizal / sample-api-load-test.js
Created July 29, 2023 03:49
sample api load test
import http from 'k6/http';
import { sleep } from 'k6';
export let options = {
stages: [
{ duration: '1m', target: 100 },
{ duration: '2m', target: 500 },
{ duration: '2m', target: 1000 },
],
};
@mrrizal
mrrizal / example_test.go
Last active February 22, 2023 07:42
Implementing Interfaces for GoCQL lib
func NewMockService(logger commons.Logger, session custom_gocql.SessionInterface) Service {
return &Service{session: session, logger: logger}
}
// InitMockFunc it's use for implelementing the interface.
// it's just mock, so just put empty function
func InitMockFunc() {
session.ExecutedQuery = []string{}
session.MockQuery = func(stmt string, val ...interface{}) custom_gocql.QueryInterface {
--extra-index-url https://${DEPLOY_TOKEN_USERNAME}:${DEPLOY_TOKEN_PASSWORD}@gitlab.com/api/v4/projects/23550133/packages/pypi/simple
hello-package==0.0.2
image: python:3.8.5
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
paths:
- .cache/pip
- venv/
pytest==6.2.1
requests==2.25.1
#!make
build:
python setup.py sdist bdist_wheel
test:
pytest
import setuptools
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
setuptools.setup(
name="hello-package",
version="0.0.2",
author="Rizal",
author_email="rizalubuntuuser@gmail.com",
from hello import Hello
def test_greeting():
hello_obj = Hello()
assert hello_obj.greeting("Rizal") == "Hello Rizal!"
def test_location():
hello_obj = Hello()
status_code, response = hello_obj.get_location()
from .hello import Hello
import requests
class Hello(object):
def greeting(self, name):
return "Hello {}!".format(name)
def get_location(self):
ip_info_url = "https://ipinfo.io/json"
r = requests.get(ip_info_url)