Skip to content

Commit

Permalink
interfaceを使うように変更
Browse files Browse the repository at this point in the history
  • Loading branch information
harakeishi committed Feb 12, 2023
1 parent 41dbd19 commit 5f6850a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion trv/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (d *DB) fetchDBInfo(client *github.Client, ctx context.Context, source Sour
continue
}
var table Table
schema, err := table.fetchTableInfoInMarkdownFromGitHub(client, ctx, source.Owner, source.Repo, path)
schema, err := table.fetchTableInfoInMarkdownFromGitHub(client.Repositories, ctx, source.Owner, source.Repo, path)
if err != nil {
return fmt.Errorf("fech DB info fail:%w", err)
}
Expand Down
8 changes: 6 additions & 2 deletions trv/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ func (t Table) getFullName(i int) string {
return t.Name + "." + t.Columns[i].Name
}

type Repositories interface {
GetContents(ctx context.Context, owner string, repo string, path string, opt *github.RepositoryContentGetOptions) (fileContent *github.RepositoryContent, directoryContent []*github.RepositoryContent, resp *github.Response, err error)
}

// Get the schema information output in markdown from GitHub.
func (t *Table) fetchTableInfoInMarkdownFromGitHub(client *github.Client, ctx context.Context, owner, repo, path string) (schema, error) {
content, _, _, err := client.Repositories.GetContents(ctx, owner, repo, path, nil)
func (t *Table) fetchTableInfoInMarkdownFromGitHub(repositories Repositories, ctx context.Context, owner, repo, path string) (schema, error) {
content, _, _, err := repositories.GetContents(ctx, owner, repo, path, nil)
if err != nil {
return "", fmt.Errorf("fetch table info fail:%w", err)
}
Expand Down

0 comments on commit 5f6850a

Please sign in to comment.