-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-shape everything to use the interface
- Loading branch information
Showing
49 changed files
with
5,194 additions
and
69 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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,12 +1,43 @@ | ||
package auth0 | ||
|
||
// API mimics `management.Management`s general interface, except it uses | ||
// methods since we can't really mock fields. | ||
type API interface { | ||
Actions() ActionsAPI | ||
Client() ClientAPI | ||
Connection() ConnectionAPI | ||
Log() LogAPI | ||
Rule() RuleAPI | ||
ResourceServer() ResourceServerAPI | ||
import ( | ||
"gopkg.in/auth0.v5" | ||
"gopkg.in/auth0.v5/management" | ||
) | ||
|
||
// API mimics `management.Management`s general interface, except it refers to | ||
// the interfaces instead of the concrete structs. | ||
type API struct { | ||
Action ActionAPI | ||
Client ClientAPI | ||
Connection ConnectionAPI | ||
Log LogAPI | ||
Rule RuleAPI | ||
ResourceServer ResourceServerAPI | ||
} | ||
|
||
func NewAPI(m *management.Management) *API { | ||
return &API{ | ||
Action: m.Action, | ||
Client: m.Client, | ||
Connection: m.Connection, | ||
Log: m.Log, | ||
ResourceServer: m.ResourceServer, | ||
Rule: m.Rule, | ||
} | ||
} | ||
|
||
// Alias all the helper methods so we can keep just typing `auth0.Bool` and the | ||
// compiler can autocomplete our internal package. | ||
var ( | ||
Bool = auth0.Bool | ||
BoolValue = auth0.BoolValue | ||
String = auth0.String | ||
StringValue = auth0.StringValue | ||
Int = auth0.Int | ||
IntValue = auth0.IntValue | ||
Float64 = auth0.Float64 | ||
Float64Value = auth0.Float64Value | ||
Time = auth0.Time | ||
TimeValue = auth0.TimeValue | ||
) |
This file was deleted.
Oops, something went wrong.
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
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,44 @@ | ||
package cli | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
"github.com/olekukonko/tablewriter" | ||
) | ||
|
||
// TODO(cyx): think about whether we should extract this function in the | ||
// `display` package. For now duplication might be better and less premature. | ||
func expectTable(t testing.TB, got string, header []string, data [][]string) { | ||
w := &bytes.Buffer{} | ||
|
||
tableString := &strings.Builder{} | ||
table := tablewriter.NewWriter(tableString) | ||
table.SetHeader(header) | ||
|
||
table.SetAutoWrapText(false) | ||
table.SetAutoFormatHeaders(true) | ||
table.SetHeaderAlignment(tablewriter.ALIGN_LEFT) | ||
table.SetAlignment(tablewriter.ALIGN_LEFT) | ||
table.SetCenterSeparator("") | ||
table.SetColumnSeparator("") | ||
table.SetRowSeparator("") | ||
table.SetHeaderLine(false) | ||
table.SetBorder(false) | ||
|
||
for _, v := range data { | ||
table.Append(v) | ||
} | ||
|
||
table.Render() | ||
fmt.Fprint(w, tableString.String()) | ||
|
||
want := w.String() | ||
|
||
if got != want { | ||
t.Fatal(cmp.Diff(want, got)) | ||
} | ||
} |
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
Oops, something went wrong.