mirror of
https://github.com/ditatompel/xmr-remote-nodes.git
synced 2025-01-08 05:52:10 +07:00
test: Unit test for parseStatuses()
This commit is contained in:
parent
58e2da0a67
commit
459271408d
1 changed files with 48 additions and 1 deletions
|
@ -2,8 +2,56 @@ package monero
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/jmoiron/sqlx/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestNode_parseStatuses(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
report Node
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Invalid initial LastCheckStatus type",
|
||||||
|
report: Node{
|
||||||
|
IsAvailable: true,
|
||||||
|
LastCheckStatus: types.JSONText("-invalid source-"),
|
||||||
|
},
|
||||||
|
want: "[2,2,2,2,1]",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Node goes online",
|
||||||
|
report: Node{
|
||||||
|
IsAvailable: true,
|
||||||
|
LastCheckStatus: types.JSONText("[0,1,0,0,0]"),
|
||||||
|
},
|
||||||
|
want: "[1,0,0,0,1]",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Node goes offline",
|
||||||
|
report: Node{
|
||||||
|
IsAvailable: false,
|
||||||
|
LastCheckStatus: types.JSONText("[0,1,0,1,1]"),
|
||||||
|
},
|
||||||
|
want: "[1,0,1,1,0]",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
n := &ProbeReport{
|
||||||
|
Node: Node{
|
||||||
|
IsAvailable: tt.report.IsAvailable,
|
||||||
|
LastCheckStatus: tt.report.LastCheckStatus,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if got := n.parseStatuses(); got != tt.want {
|
||||||
|
t.Errorf("Node.parseStatuses() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestQueryLogs_toSQL(t *testing.T) {
|
func TestQueryLogs_toSQL(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
@ -13,7 +61,6 @@ func TestQueryLogs_toSQL(t *testing.T) {
|
||||||
wantSortBy string
|
wantSortBy string
|
||||||
wantSortDirection string
|
wantSortDirection string
|
||||||
}{
|
}{
|
||||||
// TODO: Add test cases.
|
|
||||||
{
|
{
|
||||||
name: "Default query",
|
name: "Default query",
|
||||||
fields: QueryLogs{
|
fields: QueryLogs{
|
||||||
|
|
Loading…
Reference in a new issue