Skip to content

Commit

Permalink
Merge pull request #330 from IBM-Cloud/dev
Browse files Browse the repository at this point in the history
Release 0.10.1
  • Loading branch information
Aerex authored Jun 30, 2022
2 parents 999913d + 5d705f4 commit 77c38ba
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bluemix/authentication/vpc/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

const (
DefaultMetadataServiceVersion = "2021-09-30"
DefaultMetadataServiceVersion = "2022-03-01"
DefaultServerEndpoint = "http://169.254.169.254"

defaultMetadataFlavor = "ibm"
Expand Down
2 changes: 1 addition & 1 deletion bluemix/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package bluemix
import "fmt"

// Version is the SDK version
var Version = VersionType{Major: 0, Minor: 10, Build: 0}
var Version = VersionType{Major: 0, Minor: 10, Build: 1}

// VersionType describe version info
type VersionType struct {
Expand Down
44 changes: 44 additions & 0 deletions docs/plugin_developer_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,50 @@ func TestStart() {
}
```

### 6.1 Using the Test Doubles

When writing unit tests you may need to mock parts of the cli-sdk, dev-plugin, or your own interfaces. The dev-plugin uses [counterfeiter](https://github.com/maxbrunsfeld/counterfeiter) to mock interfaces that allow you to fake their implementation.

You can use the fakes implementation to mock the return, arguments, etc. Below are a few example of showing how to stub various methods in [PluginContext](https://github.com/IBM-Cloud/ibm-cloud-cli-sdk/blob/master/plugin/plugin_context.go) and [PluginConfig](https://github.com/IBM-Cloud/ibm-cloud-cli-sdk/blob/master/plugin/plugin_config.go).


```go
import (
"github.com/IBM-Cloud/ibm-cloud-cli-sdk/plugin/pluginfakes"
)
var (
context *pluginfakes.FakePluginContext
config *pluginfakes.FakePluginConfig
)

BeforeEach(func() {
context = new(pluginfakes.FakePluginContext)
config = new(pluginfakes.FakePluginConfig)

// mock the IsLoggedIn method to always return true
// NOTE: expect method signature format to be `<METHOD_NAME>Returns()`
context.IsLoggedInReturns(true)

// mock the second IsLoggedIn call return false
// NOTE: expect method signature format to be `<METHOD_NAME>ReturnsOnCall()`
context.IsLoggedInReturnsOnCall(1, false)

// stub the arguments for the first PluginConfig.Set method
// NOTE: expect method signature format to be `<METHOD_NAME>ArgsForCall(...args)`
config.SetArgsForCall("region", "us-south")
})

It("should call RefreshToken more than once", func() {

// return the number of times a method is called
// NOTE: expect method signature format to be `<METHOD_NAME>Calls()`
Expect(context.RefreshIAMTokenCalls()).Should(BeNumerically(">", 0))
})

```

You can find other examples in [tests](https://github.com/maxbrunsfeld/counterfeiter/blob/master/generated_fakes_test.go) found in counterfeiter.

## 7. Globalization

IBM Cloud CLI tends to be used globally. Both IBM Cloud CLI and its plug-ins should support globalization. We have enabled internationalization (i18n) for CLI's base commands with the help of the third-party tool "[go-i18n](https://github.com/nicksnyder/go-i18n)". To keep user experience consistent, we recommend plug-in developers follow the CLI's way of i18n enablement.
Expand Down

0 comments on commit 77c38ba

Please sign in to comment.