-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: revert changes in the chaincode
Signed-off-by: osamamagdy <[email protected]>
- Loading branch information
1 parent
79c0493
commit 57ad005
Showing
13 changed files
with
1,007 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"os" | ||
"testing" | ||
|
||
"github.com/hyperledger-labs/cc-tools/mock" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
log.SetFlags(log.Lshortfile) | ||
|
||
err := SetupCC() | ||
if err != nil { | ||
log.Println(err) | ||
os.Exit(1) | ||
} | ||
|
||
stub := mock.NewMockStub("org1MSP", new(CCDemo)) | ||
res := stub.MockInit("testInit", [][]byte{[]byte("init")}) | ||
if res.GetStatus() != 200 { | ||
log.Println(res.GetMessage()) | ||
os.Exit(1) | ||
} | ||
|
||
os.Exit(m.Run()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Feature: Create New Library | ||
In order to create a new library | ||
As an API client | ||
I want to make a request with the name of the desired library | ||
|
||
Scenario: Create a new library | ||
Given there is a running "" test network from scratch | ||
When I make a "POST" request to "/api/invoke/createNewLibrary" on port 80 with: | ||
""" | ||
{ | ||
"name": "Elizabeth's Library" | ||
} | ||
""" | ||
Then the response code should be 200 | ||
And the response should have: | ||
""" | ||
{ | ||
"@key": "library:9cf6726a-a327-568a-baf1-5881393073bf", | ||
"@lastTouchBy": "orgMSP", | ||
"@lastTx": "createNewLibrary", | ||
"@assetType": "library", | ||
"name": "Elizabeth's Library" | ||
} | ||
""" | ||
|
||
Scenario: Try to create a new library with a name that already exists | ||
Given there is a running "" test network | ||
Given there is a library with name "John's Library" | ||
When I make a "POST" request to "/api/invoke/createNewLibrary" on port 80 with: | ||
""" | ||
{ | ||
"name": "John's Library" | ||
} | ||
""" | ||
Then the response code should be 409 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Feature: Get Books By Author | ||
In order to get all the books by an author | ||
As an API client | ||
I want to make a request to the getBooksByAuthor transaction | ||
And receive the appropriate books | ||
|
||
Scenario: Request an author with multiple books | ||
Given there is a running "" test network | ||
And there are 3 books with prefix "book" by author "Jack" | ||
When I make a "GET" request to "/api/query/getBooksByAuthor" on port 80 with: | ||
""" | ||
{ | ||
"authorName": "Jack" | ||
} | ||
""" | ||
Then the response code should be 200 | ||
And the "result" field should have size 3 | ||
|
||
Scenario: Request an author with no books | ||
Given there is a running "" test network | ||
When I make a "GET" request to "/api/query/getBooksByAuthor" on port 80 with: | ||
""" | ||
{ | ||
"authorName": "Mary" | ||
} | ||
""" | ||
Then the response code should be 200 | ||
And the "result" field should have size 0 | ||
|
||
Scenario: Request an author with 2 books while there are other authors with more books | ||
Given there is a running "" test network | ||
Given there are 1 books with prefix "fantasy" by author "Missy" | ||
Given there are 2 books with prefix "cook" by author "John" | ||
When I make a "GET" request to "/api/query/getBooksByAuthor" on port 80 with: | ||
""" | ||
{ | ||
"authorName": "John" | ||
} | ||
""" | ||
Then the response code should be 200 | ||
And the "result" field should have size 2 |
63 changes: 63 additions & 0 deletions
63
chaincode/tests/features/getNumberOfBooksFromLibrary.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
Feature: Get Number Of Books From Library | ||
In order to create the number of books from library | ||
As an API client | ||
I want to make a request | ||
|
||
Scenario: Query Get Number Of Books From Library that Exists | ||
Given there is a running "" test network | ||
And I make a "POST" request to "/api/invoke/createAsset" on port 80 with: | ||
""" | ||
{ | ||
"asset": [ | ||
{ | ||
"@assetType": "book", | ||
"title": "Meu Nome é Maria", | ||
"author": "Maria Viana" | ||
} | ||
] | ||
} | ||
""" | ||
And I make a "POST" request to "/api/invoke/createAsset" on port 80 with: | ||
""" | ||
{ | ||
"asset": [{ | ||
"@assetType": "library", | ||
"name": "Maria's Library", | ||
"books": [ | ||
{ | ||
"@assetType": "book", | ||
"@key": "book:a36a2920-c405-51c3-b584-dcd758338cb5" | ||
} | ||
] | ||
}] | ||
} | ||
""" | ||
When I make a "GET" request to "/api/query/getNumberOfBooksFromLibrary" on port 80 with: | ||
""" | ||
{ | ||
"library": { | ||
"@key": "library:3cab201f-9e2b-579d-b7b2-72297ed17f49", | ||
"@assetType": "library" | ||
} | ||
} | ||
""" | ||
Then the response code should be 200 | ||
And the response should have: | ||
""" | ||
{ | ||
"numberOfBooks": 1.0 | ||
} | ||
""" | ||
|
||
Scenario: Query Get Number Of Books From Library that Does Not Exists | ||
Given there is a running "" test network | ||
When I make a "GET" request to "/api/query/getNumberOfBooksFromLibrary" on port 80 with: | ||
""" | ||
{ | ||
"library": { | ||
"@key": "library:5c5b201f-9e4c-579d-b7b2-72297ed17f78", | ||
"@assetType": "library" | ||
} | ||
} | ||
""" | ||
Then the response code should be 400 |
Oops, something went wrong.