generated from nelsonmarro/go-pro-proj-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8185f0
commit 7a51363
Showing
17 changed files
with
319 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch package", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"remotePath": "", | ||
"port": 38697, | ||
"host": "127.0.0.1", | ||
"program": "${workspaceFolder}", | ||
"env": {}, | ||
"args": [], | ||
"cwd": "${workspaceFolder}", | ||
"envFile": "${workspaceFolder}/.env", | ||
"buildFlags": "" | ||
}, | ||
{ | ||
"name": "Debug current package", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "debug", | ||
"remotePath": "", | ||
"port": 38697, | ||
"host": "127.0.0.1", | ||
"program": "${workspaceFolder}/cmd/goldwatcher/main.go", | ||
"env": {}, | ||
"args": [], | ||
"cwd": "${workspaceFolder}", | ||
"envFile": "${workspaceFolder}/.env", | ||
"buildFlags": "" | ||
}, | ||
{ | ||
"name": "Launch test function", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "test", | ||
"program": "${workspaceFolder}", | ||
"args": ["-test.run", "MyTestFunction"] | ||
}, | ||
{ | ||
"name": "Attach main", | ||
"type": "go", | ||
"request": "attach", | ||
"mode": "debug", | ||
"remotePath": "", | ||
"port": 38697, | ||
"host": "127.0.0.1", | ||
"program": "${workspaceFolder}/main.go", | ||
"env": {}, | ||
"args": [], | ||
"cwd": "${workspaceFolder}", | ||
"processId": "", | ||
"envFile": "${workspaceFolder}/.env", | ||
"buildFlags": "" | ||
}, | ||
{ | ||
"name": "Attach to Process", | ||
"type": "go", | ||
"request": "attach", | ||
"mode": "local", | ||
"processId": 0 | ||
}, | ||
{ | ||
"name": "Launch file", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "debug", | ||
"program": "${file}" | ||
} | ||
] | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,41 @@ | ||
package application | ||
|
||
import ( | ||
"slices" | ||
"testing" | ||
) | ||
|
||
func TestApp_GetHoldings(t *testing.T) { | ||
holdings, err := testApp.currentHoldings() | ||
if err != nil { | ||
t.Error("failed to get current holdings from db:", err) | ||
} | ||
|
||
if len(holdings) != 2 { | ||
t.Errorf("expected holdings slice to return 2 values, got:%v", len(holdings)) | ||
} | ||
} | ||
|
||
func TestApp_GetHoldingsSlice(t *testing.T) { | ||
slice := testApp.getHoldingsSlice() | ||
|
||
if len(slice) != 3 { | ||
t.Errorf("expected to get a holdings slice with 3 rows, but got: %v", len(slice)) | ||
} | ||
|
||
lable_row := slice[0] | ||
expected_lable_row := []interface{}{"ID", "Amount", "Price", "Date", "Options"} | ||
|
||
if !slices.Equal(lable_row, expected_lable_row) { | ||
t.Errorf("wrong values on table's lable row, expected: ['ID', 'Amount', 'Price', 'Date', 'Options'], but got: %s", lable_row) | ||
} | ||
|
||
first_holdings_row := slice[1] | ||
first_holdings_row = first_holdings_row[:len(first_holdings_row)-1] | ||
|
||
expected_first_holdings_row := []interface{}{"1", "1 toz", "$10.00", "2024-12-31"} | ||
|
||
if !slices.Equal(first_holdings_row, expected_first_holdings_row) { | ||
t.Errorf("wrong values on table's 1st row, expected: ['1', '1 toz', '$10.00', '2024-12-31'], but got: %s", first_holdings_row) | ||
} | ||
} |
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
File renamed without changes.
Oops, something went wrong.