Skip to content

Commit

Permalink
chore: remove indentation from chain serve output to make it easier t…
Browse files Browse the repository at this point in the history
…o properly copy and paste (#3522)

* chore: remove identation from chain serve output to make it easier to properly copy and paste

* refactor: accountview tests to follow tt patterns

* fix: adding missing changelog for chain serve indentation changes

* refactor: following naming convention on tests for account string

Co-authored-by: Jerónimo Albi <[email protected]>

---------

Co-authored-by: Derick Rentz <[email protected]>
Co-authored-by: Jerónimo Albi <[email protected]>
Co-authored-by: Danilo Pantani <[email protected]>
  • Loading branch information
4 people authored Jul 20, 2023
1 parent 7b93008 commit a991ee2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- [#3581](https://github.com/ignite/cli/pull/3581) Bump cometbft and cometbft-db in the template
- [#3559](https://github.com/ignite/cli/pull/3559) Bump network plugin version to `v0.1.1`
- [#3522](https://github.com/ignite/cli/pull/3522) Remove indentation from `chain serve` output

## [`v0.27.0`](https://github.com/ignite/cli/releases/tag/v0.27.0)

Expand Down
8 changes: 1 addition & 7 deletions ignite/pkg/cliui/view/accountview/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import (
"fmt"
"strings"

"github.com/muesli/reflow/indent"
"github.com/muesli/reflow/wordwrap"

"github.com/ignite/cli/ignite/pkg/cliui/colors"
"github.com/ignite/cli/ignite/pkg/cliui/icons"
)
Expand Down Expand Up @@ -48,10 +45,7 @@ func (a Account) String() string {

// The account is new when the mnemonic is available
if a.Mnemonic != "" {
m := wordwrap.String(a.Mnemonic, 80)
m = indent.String(m, 2)

return fmt.Sprintf(fmtNewAccount, icons.OK, name, a.Address, colors.Mnemonic(m))
return fmt.Sprintf(fmtNewAccount, icons.OK, name, a.Address, colors.Mnemonic(a.Mnemonic))
}

return fmt.Sprintf(fmtExistingAccount, icons.User, name, a.Address)
Expand Down
36 changes: 36 additions & 0 deletions ignite/pkg/cliui/view/accountview/account_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package accountview_test

import (
"testing"

"github.com/ignite/cli/ignite/pkg/cliui/view/accountview"
"github.com/stretchr/testify/assert"
)

func TestAccountString(t *testing.T) {
tests := []struct {
name string
account accountview.Account
want string
}{
{
name: "new account (mnemonic available) to string is not idented",
account: accountview.NewAccount("alice", "cosmos193he38n21khnmb2", accountview.WithMnemonic("person estate daughter box chimney clay bronze ring story truck make excess ring frame desk start food leader sleep predict item rifle stem boy")),
want: "✔ Added account \x1b[1malice\x1b[0m with address cosmos193he38n21khnmb2 and mnemonic:\nperson estate daughter box chimney clay bronze ring story truck make excess ring frame desk start food leader sleep predict item rifle stem boy\n",
},
{
name: "existent account to string is not idented",
account: accountview.NewAccount("alice", "cosmos193he38n21khnmb2"),
want: "👤 \x1b[1malice\x1b[0m's account address: cosmos193he38n21khnmb2\n",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := tt.account.String()

assert.NotEmpty(t, result)
assert.Equal(t, tt.want, result)
})
}
}

0 comments on commit a991ee2

Please sign in to comment.