Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Arodab/oldschoolbot
Browse files Browse the repository at this point in the history
  • Loading branch information
Arodab committed Aug 16, 2024
2 parents 4a32343 + 573a608 commit 27ba1db
Show file tree
Hide file tree
Showing 238 changed files with 7,720 additions and 3,605 deletions.
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.env
icon_cache
logs
dist
dist
node_modules
coverage
.yarn
.tests
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ BOT_TOKEN=PUT_YOUR_TOKEN_HERE
# You may need to change these:
ROBOCHIMP_DATABASE_URL=postgresql://postgres:postgres@localhost:5436/robochimp_test
DATABASE_URL=postgresql://postgres:postgres@localhost:5435/osb_test
#REDIS_PORT=6379 #OPTIONAL

# Optional
#REDIS_PORT=6379
#TESTING_SERVER_ID=123456789012345678

# Dont change these:
TZ="UTC"
3 changes: 2 additions & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ TZ="UTC"
CLIENT_ID=111398433321891634
BOT_TOKEN=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
TEST=true
CI=true
CI=true
YARN_ENABLE_HARDENED_MODE=0
2 changes: 1 addition & 1 deletion .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
uses: docker/setup-buildx-action@v3

- name: Run Integration Tests
run: docker-compose up --build --abort-on-container-exit
run: docker compose up --build --abort-on-container-exit --remove-orphans && docker compose down --volumes --remove-orphans
8 changes: 2 additions & 6 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
test:
name: Node v${{ matrix.node_version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 10
timeout-minutes: 5
strategy:
matrix:
node_version: [20.15.0]
Expand Down Expand Up @@ -43,8 +43,4 @@ jobs:
- name: Build
run: yarn build:tsc
- name: Test
run: |
yarn test:unit
yarn test:lint
tsc -p tests/integration && tsc -p tests/unit
npm i -g dpdm && dpdm --exit-code circular:1 --progress=false --warning=false --tree=false ./dist/index.js
run: yarn test:ci:unit
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ nodeLinker: node-modules
telemetryInterval: 999999999999
enableTelemetry: false
checksumBehavior: "update"
enableHardenedMode: false
2 changes: 1 addition & 1 deletion SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This assumes you are using VSCode as your IDE. If you have errors or issues, you
2. Install [Postgres 16](https://www.postgresql.org/download/) and PGAdmin4 for interacting with postgres (optional, but helpful)
3. Install Yarn using: `npm i -g yarn`
4. Clone the repo: `git clone https://github.com/oldschoolgg/oldschoolbot.git`
5. Run `corepack enable` and `yarn` in the root of the repo.
5. Run the following commands in the root of the repo: `corepack enable`, `yarn`, `npx prisma db push` and `npx prisma db push --schema ./prisma/robochimp.prisma`

### Configuration

Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ services:
depends_on:
- db
environment:
ROBOCHIMP_DATABASE_URL: postgresql://postgres:postgres@db:5435/robochimp_integration_test?connection_limit=500&pool_timeout=0&schema=public
DATABASE_URL: postgresql://postgres:postgres@db:5435/osb_integration_test?connection_limit=500&pool_timeout=0&schema=public
ROBOCHIMP_DATABASE_URL: postgresql://postgres:postgres@db:5435/robochimp_integration_test?connection_limit=10&pool_timeout=0&schema=public
DATABASE_URL: postgresql://postgres:postgres@db:5435/osb_integration_test?connection_limit=10&pool_timeout=0&schema=public
WAIT_HOSTS: db:5435

volumes:
Expand Down
94 changes: 94 additions & 0 deletions fish.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { Bank } from 'oldschooljs';
import { describe, it } from 'vitest';

import { Gear } from '../../../src/lib/structures/Gear';
import { fishCommand } from '../../../src/mahoji/commands/fish';
import { testRunCmd } from '../utils';

describe('Fish Command', () => {
it('should handle insufficient fishing level', () => {
testRunCmd({
cmd: fishCommand,
opts: { name: 'Trout/Salmon', quantity: 1 },
result: '<:minion:778418736180494347> Your minion needs 20 Fishing to fish Trout/Salmon.'
});
});

it('should handle insufficient QP', () => {
testRunCmd({
cmd: fishCommand,
opts: { name: 'karambwanji', quantity: 1 },
user: { skills_fishing: 9_999_999, QP: 0 },
result: 'You need 15 qp to catch those!'
});
});

it('should handle invalid fish', () => {
testRunCmd({
cmd: fishCommand,
opts: { name: 'asdf' },
result: 'Thats not a valid fish to catch.'
});
});

it('should handle insufficient barb fishing levels', () => {
testRunCmd({
cmd: fishCommand,
opts: { name: 'Barbarian fishing' },
user: { skills_fishing: 1 },
result: '<:minion:778418736180494347> Your minion needs 48 Fishing to fish Barbarian fishing.'
});
});

it('should fish', () => {
testRunCmd({
cmd: fishCommand,
opts: { name: 'Shrimps/Anchovies' },
result: "<:minion:778418736180494347> Your minion is now fishing Shrimps/Anchovies, it'll take around 30 minutes to finish"
});
});

it('should catch insufficient feathers', () => {
testRunCmd({
cmd: fishCommand,
opts: { name: 'Barbarian fishing' },
user: {
skills_fishing: 999_999,
skills_agility: 999_999,
skills_strength: 999_999,
meleeGear: new Gear({ weapon: 'Pearl barbarian rod' })
},
result: 'You need Feather to fish Barbarian fishing!'
});
});

it('should boost', () => {
testRunCmd({
cmd: fishCommand,
opts: { name: 'Barbarian fishing' },
user: {
skills_fishing: 999_999,
skills_agility: 999_999,
skills_strength: 999_999,
bank: new Bank().add('Feather', 1000)
},
result: `<:minion:778418736180494347> Your minion is now fishing 100x Barbarian fishing, it'll take around 6 minutes, 1 second to finish.
**Boosts:** 5% for Pearl barbarian rod.`
});
});

it('should fish barrel boost', () => {
testRunCmd({
cmd: fishCommand,
opts: { name: 'shrimps' },
user: {
skills_fishing: 999_999,
meleeGear: new Gear({ cape: 'Fish sack barrel' })
},
result: `<:minion:778418736180494347> Your minion is now fishing Shrimps/Anchovies, it'll take around 39 minutes, 1 second to finish.
**Boosts:** +9 trip minutes and +28 inventory slots for having a Fish sack barrel.`
});
});
});
Loading

0 comments on commit 27ba1db

Please sign in to comment.