-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic test for inspector (#1166)
* Add basic test for inspector * Add header * Fix return
- Loading branch information
1 parent
1fa3d4f
commit 05c7ed5
Showing
2 changed files
with
34 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
Copyright 2022 GitHub Inc. | ||
See https://github.com/github/gh-ost/blob/master/LICENSE | ||
*/ | ||
|
||
package logic | ||
|
||
import ( | ||
"testing" | ||
|
||
test "github.com/openark/golib/tests" | ||
|
||
"github.com/github/gh-ost/go/sql" | ||
) | ||
|
||
func TestInspectGetSharedUniqueKeys(t *testing.T) { | ||
origUniqKeys := []*sql.UniqueKey{ | ||
{Columns: *sql.NewColumnList([]string{"id", "item_id"})}, | ||
{Columns: *sql.NewColumnList([]string{"id", "org_id"})}, | ||
} | ||
ghostUniqKeys := []*sql.UniqueKey{ | ||
{Columns: *sql.NewColumnList([]string{"id", "item_id"})}, | ||
{Columns: *sql.NewColumnList([]string{"id", "org_id"})}, | ||
{Columns: *sql.NewColumnList([]string{"item_id", "user_id"})}, | ||
} | ||
inspector := &Inspector{} | ||
sharedUniqKeys := inspector.getSharedUniqueKeys(origUniqKeys, ghostUniqKeys) | ||
test.S(t).ExpectEquals(len(sharedUniqKeys), 2) | ||
test.S(t).ExpectEquals(sharedUniqKeys[0].Columns.String(), "id,item_id") | ||
test.S(t).ExpectEquals(sharedUniqKeys[1].Columns.String(), "id,org_id") | ||
} |