Skip to content

Commit

Permalink
added one more test and fixed readme
Browse files Browse the repository at this point in the history
  • Loading branch information
rbrtjhs committed Jul 25, 2021
1 parent e747891 commit db25794
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
32 changes: 29 additions & 3 deletions README.md
@@ -1,7 +1,33 @@
[![Build Status](https://travis-ci.com/rbrtjhs/process.svg?token=haX3CqTq2yjp6nAkGokp&branch=main)](https://travis-ci.com/rbrtjhs/process)
[![Coverage Status](https://coveralls.io/repos/github/rbrtjhs/process/badge.svg?branch=main)](https://coveralls.io/github/rbrtjhs/process?branch=main)

# Process
This project is used to manage items through specific process(es) specified by steps.
# PROCESS
This project is used machines machines and how they produce products.
The product is known as an item.
Each item is built with specific steps and collection of the specific steps is called process.
The purpose of this project is to manage items through specific process(es) specified by steps.

Process and step are ownable where process should belong to the user and step should belong to the step maker.
Process and step are ownable where process should belong to the user and step should belong to the step maker.

## USAGE
The user will create process. User will create steps and reassign each specific step to the machine. User will create an item.
The user will add steps to the specific process. The user has to add item to the process. After creation of the process user will mark the process as created by calling finishCreation().

Ice cream example:
User will create process called CHOCO ICE CREAM PROCESS which will be in status MODIFIABLE.
User will create 5 steps with names in brackets:
- Chocolate mass creation (CHOCOLATE MASS)
- Stick creation (STICK)
- Pouring chocolate mass over stick (POURING)
- Freezing (FREEZING)
- Packing (PACKING)

For each step user will assign to the specific machine which will do it's task.
User will add each step.
User will create item named CHOCO ICE CREAM.
User will finish creation. In this moment process will be in status IN_PROGRESS.

The process can start. Each step will add a detail by creating new contract instance (e.g. String detail) and adding specific details. Once it is finished will call nextStep().
With this approach each step will be responsible for itself and all data will be saved.

Once finished process will be in status FINISHED.
24 changes: 24 additions & 0 deletions test/ItemTest.js
@@ -1,12 +1,14 @@
const Process = artifacts.require('Process');
const Step = artifacts.require('Step');
const Item = artifacts.require('Item');
const StringDetail = artifacts.require('StringDetail');
const expectRevert = require("@openzeppelin/test-helpers/src/expectRevert");

contract("Item", function(accounts) {
const PROCESS_NAME = "Process 1";
const STEP_NAME = "Step 1";
const ITEM_NAME = "Item 1";
const STRING_DETAIL = "String Detail 1";

it("Should create process, step and item and link them", async () => {
let processContractInstance = await Process.new(PROCESS_NAME);
Expand All @@ -16,6 +18,28 @@ contract("Item", function(accounts) {
assert.equal(await processContractInstance.name(), PROCESS_NAME);
assert.equal(await stepContractInstance.name(), STEP_NAME);
assert.equal(await itemContractInstance.name(), ITEM_NAME);
assert.equal(await itemContractInstance.process(), processContractInstance.address);
});

it("Add detail", async () => {
let processContractInstance = await Process.new(PROCESS_NAME);
let stepContractInstance = await Step.new(STEP_NAME, processContractInstance.address);
await processContractInstance.addStep(stepContractInstance.address);
let itemContractInstance = await Item.new(ITEM_NAME, processContractInstance.address);
await processContractInstance.setItem(itemContractInstance.address);
await processContractInstance.finishCreation();
let detail = await StringDetail.new(STRING_DETAIL);
await stepContractInstance.addDetail(detail.address);
assert.equal(await itemContractInstance.details(stepContractInstance.address, 0), detail.address);
});

it("Set initial step", async () => {
let process = accounts[1];
let initialStep = accounts[2];
let item = await Item.new(ITEM_NAME, process);
await item.setInitialStep(initialStep, {from: process});
assert.equal(await item.initialStep(), initialStep);
assert.equal(await item.currentStep(), initialStep);
});

it("Prevent adding detail if not called from current step.", async () => {
Expand Down

0 comments on commit db25794

Please sign in to comment.