Skip to content

Commit

Permalink
Issue 12-13 (#14)
Browse files Browse the repository at this point in the history
added --legacy and --opdk flags in token
  • Loading branch information
rockspore authored Jul 16, 2020
1 parent 368f1a5 commit 1c90b0f
Show file tree
Hide file tree
Showing 9 changed files with 487 additions and 181 deletions.
8 changes: 4 additions & 4 deletions apigee/revision.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ type Revision int

// MarshalJSON implements the json.Marshaler interface. It marshals from
// a Revision holding an integer value like 2, into a string like "2".
func (r *Revision) MarshalJSON() ([]byte, error) {
rev := fmt.Sprintf("%d", r)
return []byte(rev), nil
}
// func (r *Revision) MarshalJSON() ([]byte, error) {
// rev := fmt.Sprintf("%d", r)
// return []byte(rev), nil
// }

// UnmarshalJSON implements the json.Unmarshaler interface. It unmarshals from
// a string like "2" (including the quotes), into an integer 2.
Expand Down
30 changes: 30 additions & 0 deletions cmd/bindings/bindings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ func TestBindingListOPDK(t *testing.T) {
"/product/",
":",
"\n",
"/product1/",
":",
"\n",
}
print.Check(t, wants)
}
Expand Down Expand Up @@ -106,6 +109,17 @@ func TestBindingAddOPDK(t *testing.T) {
}
wants = []string{"target /target/ is already bound to /product2/"}
print.Check(t, wants)

flags = []string{"bindings", "add", "/target/", "/product3/", "--opdk", "--runtime", ts.URL,
"-o", "/org/", "-e", "/env/", "-u", "/username/", "-p", "password"}
rootArgs = &shared.RootArgs{}
rootCmd = cmd.GetRootCmd(flags, print.Printf)
shared.AddCommandWithFlags(rootCmd, rootArgs, Cmd(rootArgs, print.Printf))
wantErr := "invalid product name: /product3/"
err = rootCmd.Execute()
if err == nil || err.Error() != wantErr {
t.Errorf("add want %s, got: %v", wantErr, err)
}
}

func TestBindingRemoveOPDK(t *testing.T) {
Expand Down Expand Up @@ -141,12 +155,26 @@ func TestBindingRemoveOPDK(t *testing.T) {
}
wants = []string{"product /product2/ is no longer bound to: /target/"}
print.Check(t, wants)

flags = []string{"bindings", "remove", "/target/", "/product3/", "--opdk", "--runtime", ts.URL,
"-o", "/org/", "-e", "/env/", "-u", "/username/", "-p", "password"}
rootArgs = &shared.RootArgs{}
rootCmd = cmd.GetRootCmd(flags, print.Printf)
shared.AddCommandWithFlags(rootCmd, rootArgs, Cmd(rootArgs, print.Printf))
wants = []string{"invalid product name: /product3/"}
if err = rootCmd.Execute(); err != nil {
t.Errorf("want no error, got: %v", err)
}
print.Check(t, wants)
}

func productTestServer(t *testing.T) *httptest.Server {

res := product.APIResponse{
APIProducts: []product.APIProduct{
{
Name: "/product1/",
},
{
Name: "/product/",
},
Expand All @@ -158,6 +186,8 @@ func productTestServer(t *testing.T) *httptest.Server {
Value: "/target/",
},
},
QuotaLimit: "null",
Scopes: []string{""},
},
},
}
Expand Down
Loading

0 comments on commit 1c90b0f

Please sign in to comment.