diff options
author | Emile <hanemile@protonmail.com> | 2019-02-15 01:27:45 +0100 |
---|---|---|
committer | Emile <hanemile@protonmail.com> | 2019-02-15 01:27:45 +0100 |
commit | e4901df05decd4be1034926dfcb7e1ef0401a4be (patch) | |
tree | 832d138e92da1902da20e41849f87573403ac26f | |
parent | be7534abdb7d99e3d0229be4e6189dbbd81ef64b (diff) |
created some tests for debugging, more comming soon!
-rw-r--r-- | db_actions_test.go | 48 |
1 files changed, 48 insertions, 0 deletions
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) + } + }) + } +} |