Skip to content

Commit

Permalink
Merge branch '223-add-ability-to-accept-t-c' of gitlab.bytemark.co.uk…
Browse files Browse the repository at this point in the history
…:open-source/bytemark-client into 223-add-ability-to-accept-t-c
  • Loading branch information
bryanwagg committed Feb 23, 2018
2 parents abc441e + 3fa0218 commit 6753aff
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
3 changes: 1 addition & 2 deletions cmd/bytemark/commands/assent.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ func init() {
if err != nil {
return err
}

if accountString != "" && accountNameFlag.SetFromCommandLine {
if accountString != "" && accountID == 0 {
// cant use with.Account() because this gets the account details of the person currently signed in, even if staff
account, err = billingRequests.GetAccountByBigVName(ctx.Client(), accountString)
if err != nil {
Expand Down
23 changes: 14 additions & 9 deletions cmd/bytemark/commands/assent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,42 @@ func TestAssent(t *testing.T) {
tests := []struct {
name string
input string
expected interface{}
account string
shouldErr bool
}{
{
name: "MissingArguments",
input: "",
account: "accountFromConfig",
shouldErr: true,
},
{
name: "SuccessfullyAssentsWithAccountID",
input: "--agreement 1 --person bwagg --accountid 101 --name BryanWagg --email geoff@jeff.com",
name: "SuccessfullyAssentsWithAccountID",
input: "--agreement 1 --person bwagg --accountid 101 --name BryanWagg --email geoff@jeff.com",
account: "bwagg",
},
{
name: "SuccessfullyAssentsWithAccount",
input: "--agreement 1 --person bwagg --account bwagg --name BryanWagg --email geoff@jeff.com",
name: "SuccessfullyAssentsWithAccount",
input: "--agreement 1 --person bwagg --account bwagg --name BryanWagg --email geoff@jeff.com",
account: "bwagg",
},
{
name: "AmbiguousAccount",
input: "--agreement 1 --person bwagg --account bwagg --accountid 1234",
account: "bwagg",
shouldErr: true,
},
{
name: "SuccessfullyAssentsWithAccountFromConfig",
input: "--agreement 1 --person bwagg --name BryanWagg --email geoff@jeff.com",
name: "SuccessfullyAssentsWithAccountFromConfig",
account: "accountFromConfig",
input: "--agreement 1 --person bwagg --name BryanWagg --email geoff@jeff.com",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
config, client, app := testutil.BaseTestAuthSetup(t, false, commands.Commands)
config.When("GetIgnoreErr", "account").Return("configAccount")
client.When("BuildRequest", "GET", lib.BillingEndpoint, "/api/v1/accounts?bigv_account_name=%s", []string{"bwagg"}).Return(&mocks.Request{
config.When("GetIgnoreErr", "account").Return("accountFromConfig")
client.When("BuildRequest", "GET", lib.BillingEndpoint, "/api/v1/accounts?bigv_account_name=%s", []string{test.account}).Return(&mocks.Request{
T: t,
StatusCode: 200,
ResponseObject: []billing.Account{{
Expand Down
3 changes: 0 additions & 3 deletions lib/output/types_test.go.inc
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ func isIgnoredType(t string) bool {
// billing.Assent will only be sent, never received.
case "billing.Assent":
return true
// billing.DeferredStatus will not be output.
case "billing.DeferredStatus":
return true
// billing.SPPTokenRequests will only be sent, never received.
case "billing.SPPTokenRequest":
return true
Expand Down

0 comments on commit 6753aff

Please sign in to comment.