From e4901df05decd4be1034926dfcb7e1ef0401a4be Mon Sep 17 00:00:00 2001 From: Emile Date: Fri, 15 Feb 2019 01:27:45 +0100 Subject: created some tests for debugging, more comming soon! --- db_actions_test.go | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/db_actions_test.go b/db_actions_test.go index b4baec9..133a83d 100644 --- a/db_actions_test.go +++ b/db_actions_test.go @@ -210,3 +210,51 @@ func TestInsertStar(t *testing.T) { }) } } + +func TestGetListOfStarsTree(t *testing.T) { + // define a database + db = ConnectToDB() + db.SetMaxOpenConns(75) + + type args struct { + database *sql.DB + treeindex int64 + } + tests := []struct { + name string + args args + want []structs.Star2D + }{ + { + name: "Get all stars for the treeindex 1", + args: args{ + database: db, + treeindex: 1, + }, + want: []structs.Star2D{ + { + C: structs.Vec2{300, 300}, + V: structs.Vec2{0.1, 0.3}, + M: 1, + }, + { + C: structs.Vec2{200, 200}, + V: structs.Vec2{0.1, 0.3}, + M: 2, + }, + { + C: structs.Vec2{400, 400}, + V: structs.Vec2{0.1, 0.3}, + M: 4, + }, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := GetListOfStarsTree(tt.args.database, tt.args.treeindex); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetListOfStarsTree() = %v, want %v", got, tt.want) + } + }) + } +} -- cgit 1.4.1